Imported Upstream version 0.1.16
authorMatteo F. Vescovi <mfv@debian.org>
Mon, 15 Feb 2016 20:17:05 +0000 (21:17 +0100)
committerMatteo F. Vescovi <mfv@debian.org>
Mon, 15 Feb 2016 20:17:05 +0000 (21:17 +0100)
31 files changed:
INSTALL
Makefile.in
NEWS
README
babl/Makefile.in
babl/babl-cpuaccel.c
babl/babl-cpuaccel.h
babl/babl-version.h
babl/base/Makefile.in
babl/base/type-half.c
config.h.in
configure
configure.ac
docs/Makefile.in
docs/graphics/Makefile.in
docs/graphics/babl-16x16.png
docs/graphics/babl-48x48.png
docs/graphics/babl-a4poster.png
extensions/CIE.c
extensions/Makefile.am
extensions/Makefile.in
extensions/float-half.c [new file with mode: 0644]
extensions/gggl-lies.c
extensions/gggl-table-lies.c [new file with mode: 0644]
extensions/gggl-table.c [new file with mode: 0644]
extensions/gggl.c
extensions/sse-half.c [new file with mode: 0644]
extensions/sse2-float.c
extensions/sse4-int8.c [new file with mode: 0644]
tests/Makefile.in
tools/Makefile.in

diff --git a/INSTALL b/INSTALL
index ea794e33962581e3a1fa2220bef01376622a3731..c617fd198d60281e083e2495bcc689d90f07732d 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-babl 0.1.14
+babl 0.1.16
 
     Dynamic; any to any, pixel format conversion library.
 
@@ -12,10 +12,10 @@ From a released version the following is the expected method of
 installation (or a variation on this theme):
 
      ------------------------------------------------------------
-     foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.14.tar.bz2
-     foo$ tar jxf babl-0.1.14.tar.gz
-     foo$ cd babl-0.1.14
-     foo/babl-0.1.14$ ./configure && make && sudo make install
+     foo$ wget ftp://ftp.gtk.org/pub/babl/0.1/babl-0.1.16.tar.bz2
+     foo$ tar jxf babl-0.1.16.tar.gz
+     foo$ cd babl-0.1.16
+     foo/babl-0.1.16$ ./configure && make && sudo make install
      ------------------------------------------------------------
 
 
index ec7f14e1a84e19ae50a649b98f91364f4ce7028c..265c9ce79aeffafa94831591da75ccd1b3641032 100644 (file)
@@ -277,6 +277,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -320,6 +321,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
diff --git a/NEWS b/NEWS
index ed238d705fcc7e94dccbd317b5109f6cf6c71de8..d9e8c6f9825b211d956f85d992e41ca3b2689dd1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ the news section both in the README and the webpage.
 
                                                                           -->
 
+2016-02-12 babl-0.1.16                                              </dt><dd>
+Improvements to half float reference, SIMD, and fast-paths, and CIE float fast
+paths; cleanups of fast path extensions.
+                                                                    </dd><dt>
 2015-11-19 babl-0.1.14                                              </dt><dd>
 sRGB precision tuning, stability fixes, locale fix for setting error tolerance.
                                                                     </dd><dt>
diff --git a/README b/README
index 7aa94dc5062e351e139a90ecfa3db2d8d0eaabe6..38920c5f80611029f6b184701a64ffd568f7eaa3 100644 (file)
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Babl-0.1.14
+Babl-0.1.16
 
 Contents
 
@@ -59,6 +59,9 @@ babl release. If there are significant improvements to babl when a GEGL
 release is done a babl release is most often put out just prior to the
 GEGL release.
 
+2016-02-12 babl-0.1.16
+    Improvements to half float reference, SIMD, and fast-paths, and CIE
+    float fast paths; cleanups of fast path extensions.
 2015-11-19 babl-0.1.14
     sRGB precision tuning, stability fixes, locale fix for setting
     error tolerance.
@@ -394,6 +397,23 @@ components
     saturation
     value
 
+CMYK
+
+components
+
+    cyan
+    magenta
+    yellow
+    key
+
+CMY
+
+components
+
+    cyan
+    magenta
+    yellow
+
 CIE Lab
 
 components
@@ -428,23 +448,6 @@ components
     CIE H(ab)
     A
 
-CMYK
-
-components
-
-    cyan
-    magenta
-    yellow
-    key
-
-CMY
-
-components
-
-    cyan
-    magenta
-    yellow
-
 HSLA
 
 components
@@ -1522,19 +1525,6 @@ components
 
     u8  Y
 
-B'aG'aR'aA u8
-
-bytes/pixel
-    4
-model
-    R'aG'aB'aA
-components
-
-    u8 B'a
-    u8 G'a
-    u8 R'a
-    u8 A
-
 cairo-RGB24
 
 bytes/pixel
@@ -1598,6 +1588,82 @@ components
     float saturation
     float value
 
+B'aG'aR'aA u8
+
+bytes/pixel
+    4
+model
+    R'aG'aB'aA
+components
+
+    u8 B'a
+    u8 G'a
+    u8 R'a
+    u8 A
+
+CMYK double
+
+bytes/pixel
+    32
+model
+    CMYK
+components
+
+    double cyan
+    double magenta
+    double yellow
+    double key
+
+CMY double
+
+bytes/pixel
+    24
+model
+    CMY
+components
+
+    double cyan
+    double magenta
+    double yellow
+
+CMYK float
+
+bytes/pixel
+    16
+model
+    CMYK
+components
+
+    float cyan
+    float magenta
+    float yellow
+    float key
+
+CMY float
+
+bytes/pixel
+    12
+model
+    CMY
+components
+
+    float cyan
+    float magenta
+    float yellow
+
+CMYK u8
+
+bytes/pixel
+    4
+model
+    CMYK
+components
+
+    u8 cyan
+    u8 magenta
+    u8 yellow
+    u8 key
+
 CIE Lab double
 
 bytes/pixel
@@ -1733,69 +1799,6 @@ components
     float CIE H(ab)
     float A
 
-CMYK double
-
-bytes/pixel
-    32
-model
-    CMYK
-components
-
-    double cyan
-    double magenta
-    double yellow
-    double key
-
-CMY double
-
-bytes/pixel
-    24
-model
-    CMY
-components
-
-    double cyan
-    double magenta
-    double yellow
-
-CMYK float
-
-bytes/pixel
-    16
-model
-    CMYK
-components
-
-    float cyan
-    float magenta
-    float yellow
-    float key
-
-CMY float
-
-bytes/pixel
-    12
-model
-    CMY
-components
-
-    float cyan
-    float magenta
-    float yellow
-
-CMYK u8
-
-bytes/pixel
-    4
-model
-    CMYK
-components
-
-    u8 cyan
-    u8 magenta
-    u8 yellow
-    u8 key
-
 HSLA double
 
 bytes/pixel
@@ -1927,21 +1930,21 @@ height of the bar indicates the number of conversions steps needed in a
 chain of conversions. A DHTML version is also available.
 
 
-    ▂·▃▂·▁                  ··   ·                  ·· ▁▂▂▃▃▂ ▂▃▂   ▃ ▃  ▁▁▁▂▂ ▂▁▂▁   ▂ ▂ ▃··  ···· ▁▂    ··   ··  ··  ▃ ── 0 RGBA double
+    ▂·▃▂·▁▂▁ ▃▂             ··   ·▂ ▂▃ ▃            ·· ▁▂▂▃▃▂▃▂▃▂▃ ▃▃ ▃  ▁▁▁▂▂▂▂▁▂▁▂▃▂▂▃▂▃··   ··   ····▂▁▂    ··  ··  ▃ ── 0 RGBA double
                                                                                                                          ── 1 RGB double
                                                                                                                          ── 2 RaGaBaA double
                                                                                                                          ── 3 R'G'B' double
-▂    ▃▂▁▁▂                  ▃▃   ▃                  ▃▃ ·▁▁▂▂▁ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▃ ── 4 R'G'B'A double
-·     ▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃   ▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▃▁▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ── 5 R'aG'aB'aA double
\96\81   â\96\81  Â·Â·Â·                  â\96\82â\96\82   â\96\82                  â\96\82â\96\82 Â·â\96\81â\96\81â\96\81···â\96\83â\96\83â\96\82   â\96\83 â\96\83  â\96\81â\96\81·â\96\81â\96\82â\96\81â\96\81â\96\81â\96\82â\96\81   â\96\82 â\96\82 Â·â\96\82â\96\82  â\96\82â\96\82â\96\83â\96\82 â\96\81â\96\82    â\96\82â\96\82   â\96\82â\96\82  â\96\82▂  ▁ ── 6 R'G'B' u8
\96\81   â\96\82â\96\82  Â·â\96\81                  â\96\82â\96\82   â\96\83                  â\96\82â\96\82 Â·Â·â\96\81â\96\82â\96\82â\96\81â\96\81â\96\82â\96\83â\96\82   â\96\83 â\96\83  â\96\81â\96\81â\96\81â\96\82â\96\82â\96\81â\96\82â\96\81â\96\82â\96\81   â\96\82 â\96\82 Â·â\96\82â\96\82  â\96\82â\96\82â\96\82â\96\82 â\96\81â\96\82    â\96\83â\96\83   â\96\82â\96\83  ▂▂  ▃ ── 7 R'G'B'A u8
-·   ▁▁▂  ·                  ▁▁   ▁                  ▁▁ ·▁▁▂▂▁ ▁▂▁   ▂▃▂  ···▁▁ ▁·▁·   ▁ ▁ ·▁▁  ▁▁▁▁ ·▁    ▁▁   ▁▁  ▁▁  ▃ ── 8 RGBA float
\96\81   â\96\82â\96\82â\96\81â\96\82                    â\96\82â\96\82   â\96\82                  â\96\82â\96\82 â\96\81â\96\82â\96\82â\96\83â\96\82· â\96\82â\96\83â\96\82   â\96\83 â\96\83  â\96\81â\96\81·â\96\81â\96\81 Â·â\96\81â\96\82â\96\81   â\96\82 â\96\82 Â·â\96\82â\96\82  â\96\83â\96\82â\96\82â\96\82 â\96\81â\96\82    â\96\82â\96\82   â\96\82â\96\82  â\96\82â\96\82  ▃ ── 9 RGB float
-                                                                                                                         ──10 RGB half
-                                                                                                                         ──11 RGBA half
+▂    ▃▂▁▁▂▃▂ ▂▁             ▃▃   ▃▃ ▃               ▃▃ ·▁▁▂▂▁▂▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▂▃▂▃ ▃▃ ▃▂▃▃   ▃▃   ▃▃▃▃▃▂▃    ▃▃  ▃▃  ▃ ── 4 R'G'B'A double
+·     ▃▃▁▂▃▂  ▃             ▁▁   ▁▃ ▃               ▁▁ ▂▃   ▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▂▃▃▃ ▃▃ ▂▂▁▁   ▁▁   ▁▁▁▁▃▂▃    ▁▁  ▁▁    ── 5 R'aG'aB'aA double
\96\81   â\96\82  Â·Â·Â·â\96\81â\96\81 â\96\81â\96\82             â\96\82â\96\82   â\96\82â\96\82 â\96\82â\96\83 â\96\83            â\96\82â\96\82 â\96\81â\96\81â\96\81â\96\81···â\96\82â\96\83â\96\82â\96\83 â\96\83â\96\83 â\96\83  â\96\81â\96\81·â\96\81â\96\82â\96\81â\96\81â\96\81â\96\82â\96\81â\96\82â\96\83â\96\82â\96\82â\96\83â\96\82·â\96\82â\96\83   â\96\83â\96\82   â\96\82â\96\82â\96\83â\96\82â\96\83â\96\81â\96\82    â\96\83â\96\82  â\96\83▂  ▁ ── 6 R'G'B' u8
\96\81   â\96\81â\96\82  Â·â\96\81â\96\82â\96\81 â\96\82â\96\81             â\96\82â\96\82   â\96\82â\96\82 â\96\82â\96\83 â\96\83            â\96\82â\96\82 Â·Â·â\96\81â\96\82â\96\82â\96\81â\96\81â\96\82â\96\83â\96\82â\96\83 â\96\83â\96\83 â\96\83  â\96\81â\96\81â\96\81â\96\82â\96\82â\96\82â\96\82â\96\81â\96\82â\96\81â\96\82â\96\83â\96\82â\96\82 â\96\82·â\96\82â\96\82   â\96\82â\96\82   â\96\82â\96\82â\96\82â\96\82â\96\82â\96\81â\96\82    â\96\82â\96\82  ▂▂  ▃ ── 7 R'G'B'A u8
+·   ▁▁▂  ·▁· ▂▁             ▁▁   ▁▁ ▁▂ ▂            ▁▁ ·▁▁▂▂▁▂▁▂▁▂▃▂▂▃▂  ···▁▁▁▁·▁·▁▂▁▁▂▁▂▁▁   ▁▁   ▁▁▁▁▁·▁    ▁▁  ▁▁  ▃ ── 8 RGBA float
\96\81   â\96\82â\96\83â\96\81â\96\82  Â·â\96\81 â\96\81â\96\82             â\96\82â\96\82   â\96\82â\96\82 â\96\82â\96\83 â\96\83            â\96\82â\96\83 â\96\81â\96\82â\96\81â\96\82â\96\82·â\96\81â\96\82â\96\83â\96\82â\96\83 â\96\83â\96\83 â\96\83  â\96\81â\96\81·â\96\81â\96\81··â\96\81â\96\82â\96\81â\96\82â\96\83â\96\82â\96\82â\96\83â\96\82â\96\82â\96\83â\96\82   â\96\82â\96\82   â\96\83â\96\83â\96\82â\96\82·â\96\81â\96\82    â\96\82â\96\82  â\96\82â\96\83  ▃ ── 9 RGB float
+▂   ▃▃▂▃▁  ▂ ▂▃             ▃▃   ▃▃ ▃               ▃▃ ▂▃▂▃▃▁▂▃ ▃   ▃ ▃  ▂▂▁▂▃▁▁▂▃▂▃ ▃▃ ▃▃▃▃   ▃▃   ▃▃▃▃▁▃▃    ▃▃  ▃▃  ▃ ──10 RGB half
+▁   ▂▂▃▂·▁   ▃▂             ▂▂   ▂▂ ▂▃ ▃            ▂▂ ▁▂▂▃▃▂▃▂▃▃▃ ▃▃ ▃  ▁▁▁▂▂▂▂▁▂▁▂▃▂▂▃▂▃▂▂   ▂▂   ▂▂▂▂▂▁▂    ▂▂  ▂▂  ▃ ──11 RGBA half
                                                                                                                          ──12 RaGaBaA half
-                                                                                                                         ──13 R'G'B' half
-                                                                                                                         ──14 R'G'B'A half
+▃   ▂ ▁▂▂▁▂▃  ▂                                        ▁▂▁▂▂·▁           ▃▃▂▃▃▂▂▃ ▃     ▃▂              ▂▃             ▃ ──13 R'G'B' half
+▂   ▁▃▂▁▁▂▃▂                ▃▃   ▃▃ ▃               ▃▃ ·▁▁▂▂▁▂▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▂▃▂▃ ▃▃ ▃▂▃▃   ▃▃   ▃▃▃▃▃▂▃    ▃▃  ▃▃  ▃ ──14 R'G'B'A half
                                                                                                                          ──15 R'aG'aB'aA half
                                                                                                                          ──16 RGB u15
                                                                                                                          ──17 RGBA u15
@@ -1955,18 +1958,18 @@ chain of conversions. A DHTML version is also available.
                                                                                                                          ──25 R'G'B' u32
                                                                                                                          ──26 R'G'B'A u32
                                                                                                                          ──27 R'aG'aB'aA u32
-·   â\96\83â\96\81â\96\83â\96\83â\96\81â\96\82                   â\96\81   â\96\81                  â\96\81â\96\81 â\96\82â\96\83â\96\83â\96\83â\96\83â\96\83 â\96\83 â\96\83   â\96\83 â\96\83  â\96\82â\96\82â\96\82â\96\83â\96\83 â\96\83â\96\82â\96\83    â\96\83   â\96\83â\96\81â\96\81  â\96\81â\96\81â\96\81â\96\81 â\96\82â\96\83    â\96\81â\96\81   ▁▁  ▁▁    ──28 Y double
-·   â\96\83â\96\81â\96\83â\96\83â\96\81â\96\83                       â\96\81                  â\96\81â\96\81 â\96\82â\96\83â\96\83â\96\83â\96\83â\96\83 â\96\83 â\96\83   â\96\83 â\96\83  â\96\82â\96\82â\96\82â\96\83â\96\83 â\96\83 â\96\83â\96\82     â\96\83 â\96\83â\96\81â\96\81  â\96\81â\96\81â\96\81â\96\81 â\96\82â\96\83    â\96\81â\96\81   ▁▁  ▁▁    ──29 YA double
+·   â\96\83â\96\81â\96\82â\96\83â\96\81â\96\82â\96\83â\96\82  â\96\83              â\96\81   â\96\81â\96\83                 â\96\81â\96\81 â\96\82â\96\83â\96\83â\96\83â\96\83â\96\83 â\96\83 â\96\83   â\96\83 â\96\83  â\96\82â\96\82â\96\82â\96\83â\96\83â\96\83â\96\83â\96\82â\96\83 â\96\83  â\96\83  â\96\82â\96\81â\96\81   â\96\81â\96\81   â\96\81â\96\81â\96\81â\96\81â\96\83â\96\82â\96\83    ▁▁  ▁▁    ──28 Y double
+·   â\96\83â\96\81â\96\82â\96\83â\96\81â\96\82â\96\83â\96\82  â\96\83                  â\96\81  â\96\83               â\96\81â\96\81 â\96\82â\96\83â\96\83â\96\83â\96\83â\96\83 â\96\83 â\96\83   â\96\83 â\96\83  â\96\82â\96\82â\96\82â\96\83â\96\83â\96\83â\96\83 â\96\83â\96\83  â\96\83  â\96\83â\96\82â\96\81â\96\81   â\96\81â\96\81   â\96\81â\96\81â\96\81â\96\81â\96\83â\96\82â\96\83    ▁▁  ▁▁    ──29 YA double
                                                                                                                          ──30 YaA double
                                                                                                                          ──31 Y' double
                                                                                                                          ──32 Y'A double
-·   ▃▁▂▃▁▂                  ▁▁                      ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▃▁▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ──33 Y'aA double
-                                                                                                                         ──34 YA half
+·   ▃▁▂▃▁▂▃▂  ▃             ▁▁    ▃ ▃               ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▂▃▂▃ ▃▃ ▃▂▁▁   ▁▁   ▁▁▁▁▃▂▃    ▁▁  ▁▁    ──33 Y'aA double
+▂   ▃▃▃▃▁▂▃▂  ▃             ▃▃      ▂▂ ▃            ▃▃ ▂▃▃▃▃▃ ▁▂▂▂▃▃▂▃▃  ▂▂▂▃▃▃▃·▁▁▁▂▂▁▂▂▂▃▃   ▃▃   ▃▃▃▃▃▂▁    ▃▃  ▃▃    ──34 YA half
                                                                                                                          ──35 YaA half
-                                                                                                                         ──36 Y half
-                                                                                                                         ──37 Y'A half
+▃     ▃▃▂▁▂▃ ▃                    ▂  ▃ ▂               ▃ ▃ ▃▂▃▂▂▁▃▃▂▃▃▂  ▃▃▂▃▃▂▂▁▁·▂▂▁▂▂▁▂              ▂▃▂            ▃ ──36 Y half
+▃   ▂ ▃▂▂▃ ▃ ▃▂                   ▂    ▂               ▁▂▂▃▃▂▃·▁▁▁▃▂▁▃▂  ▃▃▃   ▃▁▂▂▂▃▃▂▃▃▃               ▃▂              ──37 Y'A half
                                                                                                                          ──38 Y'aA half
-                                                                                                                         ──39 Y' half
+    ▃ ▂▃▃▂▃  ▂▃                   ▃ ▂▂                 ▂▃▂▃▃▁▂▁▁·▂▂▁▂▂▁    ▃  ▃▃▂▂▁▃▃▂▃▃▂▃              ▃ ▃            ▃ ──39 Y' half
                                                                                                                          ──40 YA u15
                                                                                                                          ──41 YaA u15
                                                                                                                          ──42 Y u15
@@ -1979,81 +1982,19 @@ chain of conversions. A DHTML version is also available.
                                                                                                                          ──49 Y'A u32
                                                                                                                          ──50 Y'aA u32
                                                                                                                          ──51 Y' u32
-·   ▃▁▃▃▁▂                  ▁▁   ▁                   ▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▃▁▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ──52 Y'CbCr double
-·   ▃▁▃▃▁▂                  ▁▁   ▁                     ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▁▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ──53 Y'CbCrA double
+·   ▃▁▃▃▁▂▃▂  ▃             ▁▁   ▁▃ ▃                ▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▃▃▂▃  ▃ ▃▂▁▁   ▁▁   ▁▁▁▁▃▂▃    ▁▁  ▁▁    ──52 Y'CbCr double
+·   ▃▁▃▃▁▂▃▂  ▃             ▁▁   ▁▃ ▃                  ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▂▃▂▃ ▃▃ ▂▂▁▁   ▁▁   ▁▁▁▁▃▂▃    ▁▁  ▁▁    ──53 Y'CbCrA double
                                                                                                                          ──54 Y'CbCr u8
-▁   ·▂▁··▁                  ▂▂   ▃                  ▂▂  ··▁▁· ▂▃▂   ▃ ▃  ▁▁▁▂▂ ▂▁▂▂   ▂ ▂ ▁▂▂  ▂▂▂▂ ▁▂    ▂▂   ▂▂  ▂▂  ▂ ──55 R'G'B'A float
-▂   ▁▃▂▁▁▂                  ▃▃   ▃                  ▃▃   ·▁▁▁▁▃ ▃   ▃ ▃  ▂▂▂▃▃▂▃▂▃▃   ▃ ▃ ▂▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▂ ──56 R'G'B'A u16
-▂   ▁ ▂▁▁▂                  ▃▃   ▃                  ▃▃ ·  ··▁ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▁ ──57 R'aG'aB'aA float
-▃   ▂ ▃▂▂▃                  ▃▃   ▃                  ▃▃ ▁▂  ·▂▂▃ ▃   ▃ ▃  ▃▃▃▃▃▃▃▃▃▃   ▃ ▃ ▃▃▃  ▃▃▃▃ ▃▃    ▃▃   ▃▃  ▃▃  ▁ ──58 R'aG'aB'aA u16
-▃   ▂   ▂▃                                             ▁▂·  ▂▂           ▃▃▃ ▃▃▃▃ ▃     ▃           ▃                  · ──59 R'aG'aB'aA u8
-▂   ▃▃·▁▁·                  ▃▃   ▃                  ▃▃ ▂▃▃▃   ▃ ▃   ▃ ▃  ▂▂▁▂▂ ▁▂▃▂   ▃ ▃ ▁▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▂ ──60 R'G'B' float
-▃     ·▁▂▁                                             ▃ ▃ ▁             ▃▃▃▃▃▃▂▃ ▃     ▃ ▁         ▃                  ▂ ──61 R'G'B' u16
-▂   ▁▃▂▁▁▂                  ▃▃   ▃                  ▃▃ ·▁▁▂▂▁  ·· ▂ ·▁▁  ▂▂▂▃▃ ▃·▁▁   ▁ ▂ ▂▃▃  ▃▃▃▃ ▂▁    ▃▃   ▃▃  ▃▃  ▃ ──62 Y'A float
-▃   ▂ ▃▂▂▃                                             ▁▂·▁▁▂   ▁ ▁ ▁·▂  ▃▃▃   ▃▁▂▂   ▂ ▃ ▃         ▃▂                 ▂ ──63 Y'aA float
-▃   ▂ ▁▂▂▁                                             ▁▂▁▂▂· ·     ▁ ·  ▃▃▂▃▃ ▂▁▁·   ▂ ▁ ▂         ▃▂                 ▃ ──64 Y' float
-▃   ▂ ▃▃▂▃                       ▃                     ▁▂▂▃▃▂▂·▂  ▃ ·▃▃  ▃▃▃ ▃▃▃▁▂▂   ▂ ▃ ▃         ▃▂                 ▃ ──65 Y'A u16
-    ▃  ▃                                               ▂▃▁▂▂▃ ▁·▂   ▂▁▃          ▃                   ▃                 ▃ ──66 Y'aA u16
-    ▃ ▃▃▃▂                                             ▂▃▂▃▃▁▃▁▁·   ▃▃·    ▃   ▃▂▂▁   ▃ ▂ ▃          ▃                 ▂ ──67 Y' u16
-▁   ▂▃▃▂·▂                  ▂▂   ▂                  ▂▂ ▁▃▂▃▃▂▂·▁▁·▃  ▂▂  ▁▁▂▂▂▁▂·▁▁   ▁ ▂ ▃▂▂  ▂▃▂▂ ▁▁    ▃▃   ▃▂  ▂▂  ▃ ──68 Y'A u8
-    ▃   ▃                                              ▂▃▁▂▂▃ ▁·▂ ·             ▃▃▃                  ▃                 ▃ ──69 Y'aA u8
-▁   ▃▂▂▃·▁                  ▂▂   ▂                  ▂▂ ▂▃▂▃▃▁▃▁▁·▃▃·▂    ▁▁▂▃▂▁▂▁▁·   ▂ ▁ ▃▂▂  ▂▂▂▂ ▃▂    ▂▂   ▂▂  ▂▂  ▃ ──70 Y' u8
-▃     ▁▂▂▁                                             ▃ ▃ ▂·            ▃▃▂▃▃ ▂▃ ▃     ▃ ▂         ▃                  ▃ ──71 Y'CbCr float
-▂   ▁▃▂▁▁▂                  ▃▃   ▃                  ▃  ·▁▁▂▂▁ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▃▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▃ ──72 Y'CbCrA float
-▁   ▂▂▃▂·▁                  ▂▂   ▂                  ▂▂ ▁▂▂▃▂▂▂▂▃▂   ▃ ▃   ··▂▁▁▂▁▂▁   ▂ ▂ ▃▂▂  ▂▂▂▂ ▂▂    ▂▃   ▃▂  ▂▂  ▃ ──73 RGBA u16
-▁   ▂▂▂▂·▁                  ▂▂   ▂                  ▃▃ ▁▂▂▃▃▂▂▂▃▂   ▃ ▃    ·▂▁▁·▁▂▁   ▂ ▂ ▂▂▃  ▂▂▂▂ ▁▂    ▃▂   ▂▂  ▂▂  ▃ ──74 RGBA u8
-▁   ▂▂▃▂·▁                  ▂▂   ▂                  ▂▂ ▁▂▂▃▃▂ ▂▃▂   ▃ ▃  ▁  ·· ▂▁▂▁   ▂ ▂ ▃▂▂  ▂▂▂▂ ▁▂    ▂▂   ▂▂  ▂▂  ▃ ──75 RaGaBaA float
-▂   ▃▃▂▃▁▂                  ▃▃   ▃                  ▃▃ ▂▃▃▃▃▃▃▃ ▃   ▃ ▃  ▂▂  ·▂▃▂▃▂   ▃ ▃ ▂▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▃ ──76 RaGaBaA u16
-▂   ▃▃▂▃▁▂                  ▃▃   ▃                  ▃▃ ▂▃▃▂▃▃▃▃ ▃   ▃ ▃  ▂ ·  ▂ ▂▃▂   ▃ ▃ ▂▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▃ ──77 RaGaBaA u8
-▂   ▃▃▂▃▁·                  ▃▃   ▃                  ▃▃ ▂▃▃▃▃▁▃▃ ▃   ▃ ▃  ▂▁▁▂  ·▂▃▃   ▃ ▃ ▃▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃  ▃ ──78 RGB u16
-▁   ▂▂▁▂··                  ▂▂   ▂                  ▃▂ ▁▂▂▃▂▁▃▃▃▂   ▃ ▃  ▁··▁·  ▁▂▁   ▂ ▂ ▂▂▂  ▂▂▃▂ ▂▂    ▂▂   ▂▂  ▂▂  ▃ ──79 RGB u8
-▁   ▂▂▃▂·▁                  ▂    ▂                  ▂▂ ▁▂▂▃▃▂ ·▁▁ ▃ ▁▃▂  ▁▁▁▂▂   ··   · ▁ ▃▂▂  ▂▂▂▂ ▁·    ▂▂   ▂▂  ▂▂  ▃ ──80 YA float
-▂   ▃▃▂▃▁▂                  ▃▃   ▃                  ▃▃ ▂▃▃▃▃▃ ▃▃▃   ▂▃▃  ▂▂·▁▁ ▃  ▂   ▁ ▂ ▃▃▃  ▃▃▃▃ ▂▃    ▃▃   ▃▃  ▃▃    ──81 YaA float
-▂   ▃▃▂▃▁·                   ▃   ▃                  ▃▃ ▂▃▂▃▃▁ ▁▁·   ▂▃▁  ▂▂▁▂▂ ▁·     ▁ · ▃▃▃  ▃▃▃▃ ▂▁    ▃▃   ▃▃  ▃▃  ▃ ──82 Y float
-▂   ▃▃ ▃▁▂                  ▃    ▃                  ▃▃ ▂▃▃▃▃▃▃▁▃▂   ▂▃▃  ▂▂▂▃▃▂▃·▁    · ▃  ▃▃  ▃▃▃▃ ▂▁    ▃    ▃▃  ▃▃    ──83 YA u16
-▃     ▃ ▂▃                                             ▃ ▃▃▃  ▂▃▃        ▃▃▁▂▂▃▃▃·▃     ▃ ▃         ▃▂                   ──84 YaA u16
-▃     ▃ ▂▁                                             ▃ ▃  ▂ ▂▃▁   ▃ ▂  ▃▂▂▃▃▃▃▁▁·   ▃ ·           ▃▂                   ──85 Y u16
-▁   ▃▃▃▃·▂                  ▂▂   ▂                  ▂▃ ▂▃▃▃▃▃▃▁▂▂   ▂▃▃  ▂▁▁▂▂▃▃·▁▁·    ▂ ▃▃▃  ▃▃▂▃ ▂▁    ▃▂   ▃▂  ▂▃  ▃ ──86 YA u8
-▃     ▃ ▂▃                                             ▃ ▃▃▃  ▂▃▃        ▃ ▁▂▂▃ ▁·▂ ·     ▃         ▃▂                   ──87 YaA u8
-▁   ▂▂▃▃·▁                  ▂▂   ▂                  ▂▂ ▃▂▃▃▃▂▂▂▂▁   ▃ ▁  ▁▁▂▃▂▃▂▁▁·▃ ·▂   ▂▂▂  ▂▂▂▂ ▃▂    ▂▂   ▂▂  ▂▂  ▃ ──88 Y u8
-                                                                                                                         ──89 B'aG'aR'aA u8
-                                                                                                                         ──90 cairo-RGB24
-·   ▃▁▂▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃   ▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ──91 HSVA double
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▃▃▂   ▃ ▃ ▃    ▁▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ──92 HSV double
-                                                                                                                         ──93 HSVA float
-                                                                                                                         ──94 HSV float
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▃   ▃ ▃ ▃▁▁   ▁▁▁ ▂▃    ▁▁   ▁▁  ▁▁    ──95 CIE Lab double
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▁▁    ▁▁       ▁▁   ▁▁  ▁▁    ──96 CIE Lab alpha double
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▃▃▂   ▃ ▃ ▂▁▁  ▁  ▁ ▂▃    ▁▁   ▁▁  ▁▁    ──97 CIE LCH(ab) double
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▁▁  ▁▁   ▂▃    ▁▁   ▁▁  ▁▁    ──98 CIE LCH(ab) alpha double
-                                                                                                                         ──99 CIE Lab float
-▁   ▂▂▃▂·▁                  ▂▂   ▂                  ▂▂ ▁▂▂▃▃▂ ▂▃▂   ▃ ▃  ▁▁▁▂▂ ▂▁▂▁   ▂ ▂ ▁▂▂  ▂ ▂▂       ▂▂   ▂▂  ▂▂  ▃ ──100 CIE Lab alpha float
-                                                                                                                         ──101 CIE L alpha float
-                                                                                                                         ──102 CIE Lab u8
-                                                                                                                         ──103 CIE Lab u16
-                                                                                                                         ──104 CIE LCH(ab) float
-                                                                                                                         ──105 CIE LCH(ab) alpha float
-·   ▃▁▂▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▁▁  ▁▁▁▁ ▂▃     ▁   ▁▁  ▁▁    ──106 CMYK double
-·   ▃▁▂▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▃   ▃ ▂ ▃▁▁  ▁▁▁▁ ▂▃         ▁▁  ▁▁    ──107 CMY double
-                                                                                                                         ──108 CMYK float
-                                                                                                                         ──109 CMY float
-                                                                                                                         ──110 CMYK u8
-·   ▃▁▂▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▃▁▁  ▁▁▁▁ ▂▃    ▁▁    ▁  ▁▁    ──111 HSLA double
-·   ▃▁▂▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▃▃▃   ▃ ▂ ▂▁▁  ▁▁▁▁ ▂▃    ▁▁       ▁▁    ──112 HSL double
-                                                                                                                         ──113 HSLA float
-                                                                                                                         ──114 HSL float
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▃   ▃ ▃ ▂▁▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁   ▁    ──115 Y'CbCr709 double
-·   ▃▁▃▃▁▂                  ▁▁   ▁                  ▁▁ ▂▃▃▃▃▃ ▃ ▃   ▃ ▃  ▂▂▂▃▃ ▃▂▃▂   ▃ ▃ ▂▁▁  ▁▁▁▁ ▂▃    ▁▁   ▁▁        ──116 Y'CbCrA709 double
-                                                                                                                         ──117 Y'CbCrA709 float
-                                                                                                                         ──118 Y'CbCr709 float
-                                                                                                                         ──119 cairo-ARGB32
-                                                                                                                         ──120 cairo-A8
-|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
-||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||111111111111111111111
-||||||||||111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112
-0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
-total length: 7788
-total cost  : 20663828
+▁   ·▂▁··▁▂▁ ▁·             ▂▂   ▃▂ ▂▃ ▃            ▂▂  ··▁▁·▁▂▃▂▃ ▃▃ ▃  ▁▁▁▂▂▂▂▁▂▁▂▃▂▂▃▃▁▂▂   ▂▂   ▂▂▂▂▂▁▂    ▂▂  ▂▂  ▂ ──55 R'G'B'A float
+▂   ▁▃▂·▁▂▃▂ ▂▁             ▃▃   ▃▃ ▃               ▃▃   ·▁▁▁▁▃ ▃   ▃ ▃  ▂▂▃▃▃▂▃▂▃▂▃ ▃▃ ▃▂▃▃   ▃▃   ▃▃▃▃▃▂▃    ▃▃  ▃▃  ▂ ──56 R'G'B'A u16
+▂   ▁ ▂▁▁▂▃▂ ▂▁             ▃▃   ▃▃ ▃               ▃▃ ·  ··▁▂▃ ▃   ▃ ▃  ▂▂▂▃▃▃▃▂▃▃▃ ▃▃ ▃▂▃▃   ▃▃   ▃▃▃▃▃▂▃    ▃▃  ▃▃  ▁ ──57 R'aG'aB'aA float
+▃   ▂ ▃▂▂▃▃▃ ▃▂             ▃▃   ▃▃ ▃               ▃▃ ▁▂  ·▂▃▃ ▃   ▃ ▃  ▃▃▃▃▃▃▃▃▃▃▃ ▃▃ ▃▃▃▃   ▃▃   ▃▃▃▃▃▃▃    ▃▃  ▃▃  ▁ ──58 R'aG'aB'aA u16
+▃   ▂   ▂▃ ▃ ▃▂                                        ▁▂·  ▂▂           ▃▃▃ ▃▃▃▃ ▃     ▃                ▃             · ──59 R'aG'aB'aA u8
+▂   ▁▃·▁▁·▁▂ ·▁             ▃▃   ▃▃ ▃               ▃▃ ·▁·▁  ·▃ ▃   ▃ ▃  ▂▂▁▃▂▁▁▂▃▂▃ ▃▃ ▃▁▃▃   ▃▃   ▃▃▃▃▁▂▃    ▃▃  ▃▃  ▂ ──60 R'G'B' float
+▃   ▂ ·▁▂▁▂▃ ▁▂                                        ▁▂▁▂▁             ▃▃▂▃▃▂▂▃ ▃     ▃▁              ▂▃             ▂ ──61 R'G'B' u16
+▂   ▁▃▂▁▁▂▃▂ ▂▁             ▃▃   ▃▁ ▂· ▁            ▃▃ ·▁▁▂▂▁  ···▁▁·▁▁  ▂▂▂▃▃▃▃·▁▁▁▂▂▁▂▂▃▃▃   ▃▃   ▃▃▃▃▃▂▁    ▃▃  ▃▃  ▃ ──62 Y'A float
+▃   ▂ ▃▂▂▃ ▃ ▃▂                   ▂ ▃▁ ▂               ▁▂·▁▁▂▃  ▁▁▁▂▁·▂  ▃▃▃   ▃▁▂▂▂▃▃▂▃▃▃               ▃▂            ▂ ──63 Y'aA float
+▃   ▂ ▁▂▂▁▂▃ ▁▂                   ▂ ▁▁ ·               ▁▂▁▂▂·▁·  ▁▁·▁▁·  ▃▃▂▃▃▂▂▁▁·▂▂▁▂▂▁▂              ▂▃▂            ▃ ──6
 
 Environment
 
@@ -2188,4 +2129,4 @@ Jon Nordby
 Massimo Valentini
     stability fixes
 
-/babl-0.1.14
+/babl-0.1.16
index e5a4de424c870f14db0762373caa3340d0a76853..ba7305dd77744ce2b86f459c9c8c8972b2f17ff5 100644 (file)
@@ -302,6 +302,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -345,6 +346,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
index 3445cf6c628a0d7957aeb2842089a5a91cba2510..59fdcddd31e732d4c39a3cf2bf4ef0e573d28738 100644 (file)
@@ -114,7 +114,12 @@ enum
 
 enum
 {
-  ARCH_X86_INTEL_FEATURE_PNI      = 1 << 0
+  ARCH_X86_INTEL_FEATURE_PNI      = 1 << 0,
+  ARCH_X86_INTEL_FEATURE_SSSE3    = 1 << 9,
+  ARCH_X86_INTEL_FEATURE_SSE4_1   = 1 << 19,
+  ARCH_X86_INTEL_FEATURE_SSE4_2   = 1 << 20,
+  ARCH_X86_INTEL_FEATURE_AVX      = 1 << 28,
+  ARCH_X86_INTEL_FEATURE_F16C     = 1 << 29,
 };
 
 #if !defined(ARCH_X86_64) && (defined(PIC) || defined(__PIC__))
@@ -234,6 +239,15 @@ arch_accel_intel (void)
 
     if (ecx & ARCH_X86_INTEL_FEATURE_PNI)
       caps |= BABL_CPU_ACCEL_X86_SSE3;
+
+    if (ecx & ARCH_X86_INTEL_FEATURE_SSSE3)
+      caps |= BABL_CPU_ACCEL_X86_SSSE3;
+
+    if (ecx & ARCH_X86_INTEL_FEATURE_SSE4_1)
+      caps |= BABL_CPU_ACCEL_X86_SSE4_1;
+
+    if (ecx & ARCH_X86_INTEL_FEATURE_F16C)
+      caps |= BABL_CPU_ACCEL_X86_F16C;
 #endif /* USE_SSE */
   }
 #endif /* USE_MMX */
@@ -399,7 +413,11 @@ arch_accel (void)
 
 #ifdef USE_SSE
   if ((caps & BABL_CPU_ACCEL_X86_SSE) && !arch_accel_sse_os_support ())
-    caps &= ~(BABL_CPU_ACCEL_X86_SSE | BABL_CPU_ACCEL_X86_SSE2);
+    caps &= ~(BABL_CPU_ACCEL_X86_SSE   |
+              BABL_CPU_ACCEL_X86_SSE2  |
+              BABL_CPU_ACCEL_X86_SSE3  |
+              BABL_CPU_ACCEL_X86_SSSE3 |
+              BABL_CPU_ACCEL_X86_SSE4_1);
 #endif
 
   return caps;
index e701e2afdd14525ae5369e463a0dea7ca5beca55..8040d730fe2cf6f24231c72a0fc22c6ac9d0613b 100644 (file)
@@ -30,6 +30,11 @@ typedef enum
   BABL_CPU_ACCEL_X86_SSE     = 0x10000000,
   BABL_CPU_ACCEL_X86_SSE2    = 0x08000000,
   BABL_CPU_ACCEL_X86_SSE3    = 0x02000000,
+  BABL_CPU_ACCEL_X86_SSSE3   = 0x00800000,
+  BABL_CPU_ACCEL_X86_SSE4_1  = 0x00400000,
+  /* BABL_CPU_ACCEL_X86_SSE4_2  = 0x00200000, */
+  /* BABL_CPU_ACCEL_X86_AVX     = 0x00080000, */
+  BABL_CPU_ACCEL_X86_F16C    = 0x00040000,
 
   /* powerpc accelerations */
   BABL_CPU_ACCEL_PPC_ALTIVEC = 0x04000000,
index 618856552975a3754f6bb9cd7a54f189d091707e..172d6fe0198a0906f777cac2a7e57286b98403a7 100644 (file)
@@ -34,7 +34,7 @@
 
 #define BABL_MAJOR_VERSION 0
 #define BABL_MINOR_VERSION 1
-#define BABL_MICRO_VERSION 14
+#define BABL_MICRO_VERSION 16
 
 /** Get the version information on the babl library */
 void   babl_get_version (int *major,
index 95ded472e7236aebf0e5381c19293ab055fdd747..b1b24537d3cc0b062bbd3e9b7430263fa6a9348a 100644 (file)
@@ -216,6 +216,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -259,6 +260,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
index e45e34ad67a040774f8bcec3e9f18425fd2b8724..61a63cac378b0760980bd916fa03c705a4b8e1db 100644 (file)
@@ -129,114 +129,6 @@ static void doubles2halfp(void *target, void *source, long numel)
     }
 }
 
-#if 0
-//-----------------------------------------------------------------------------
-
-static void halfp2singles(void *target, void *source, long numel)
-{
-    uint16_t *hp = (uint16_t *) source; // Type pun input as an unsigned 16-bit int
-    uint32_t *xp = (uint32_t *) target; // Type pun output as an unsigned 32-bit int
-    uint16_t h, hs, he, hm;
-    uint32_t xs, xe, xm;
-    int32_t xes;
-    int e;
-    
-    if( source == NULL || target == NULL ) // Nothing to convert (e.g., imag part of pure real)
-        return;
-    while( numel-- ) {
-        h = *hp++;
-        if( (h & 0x7FFFu) == 0 ) {  // Signed zero
-            *xp++ = ((uint32_t) h) << 16;  // Return the signed zero
-        } else { // Not zero
-            hs = h & 0x8000u;  // Pick off sign bit
-            he = h & 0x7C00u;  // Pick off exponent bits
-            hm = h & 0x03FFu;  // Pick off mantissa bits
-            if( he == 0 ) {  // Denormal will convert to normalized
-                e = -1; // The following loop figures out how much extra to adjust the exponent
-                do {
-                    e++;
-                    hm <<= 1;
-                } while( (hm & 0x0400u) == 0 ); // Shift until leading bit overflows into exponent bit
-                xs = ((uint32_t) hs) << 16; // Sign bit
-                xes = ((int32_t) (he >> 10)) - 15 + 127 - e; // Exponent unbias the halfp, then bias the single
-                xe = (uint32_t) (xes << 23); // Exponent
-                xm = ((uint32_t) (hm & 0x03FFu)) << 13; // Mantissa
-                *xp++ = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
-            } else if( he == 0x7C00u ) {  // Inf or NaN (all the exponent bits are set)
-                if( hm == 0 ) { // If mantissa is zero ...
-                    *xp++ = (((uint32_t) hs) << 16) | ((uint32_t) 0x7F800000u); // Signed Inf
-                } else {
-                    *xp++ = (uint32_t) 0xFFC00000u; // NaN, only 1st mantissa bit set
-                }
-            } else { // Normalized number
-                xs = ((uint32_t) hs) << 16; // Sign bit
-                xes = ((int32_t) (he >> 10)) - 15 + 127; // Exponent unbias the halfp, then bias the single
-                xe = (uint32_t) (xes << 23); // Exponent
-                xm = ((uint32_t) hm) << 13; // Mantissa
-                *xp++ = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
-            }
-        }
-    }
-}
-
-static void singles2halfp(void *target, void *source, long numel)
-{
-    uint16_t *hp = (uint16_t *) target; // Type pun output as an unsigned 16-bit int
-    uint32_t *xp = (uint32_t *) source; // Type pun input as an unsigned 32-bit int
-    uint16_t    hs, he, hm;
-    uint32_t x, xs, xe, xm;
-    int hes;
-    
-    if( source == NULL || target == NULL ) { // Nothing to convert (e.g., imag part of pure real)
-        return;
-    }
-    while( numel-- ) {
-        x = *xp++;
-        if( (x & 0x7FFFFFFFu) == 0 ) {  // Signed zero
-            *hp++ = (uint16_t) (x >> 16);  // Return the signed zero
-        } else { // Not zero
-            xs = x & 0x80000000u;  // Pick off sign bit
-            xe = x & 0x7F800000u;  // Pick off exponent bits
-            xm = x & 0x007FFFFFu;  // Pick off mantissa bits
-            if( xe == 0 ) {  // Denormal will underflow, return a signed zero
-                *hp++ = (uint16_t) (xs >> 16);
-            } else if( xe == 0x7F800000u ) {  // Inf or NaN (all the exponent bits are set)
-                if( xm == 0 ) { // If mantissa is zero ...
-                    *hp++ = (uint16_t) ((xs >> 16) | 0x7C00u); // Signed Inf
-                } else {
-                    *hp++ = (uint16_t) 0xFE00u; // NaN, only 1st mantissa bit set
-                }
-            } else { // Normalized number
-                hs = (uint16_t) (xs >> 16); // Sign bit
-                hes = ((int)(xe >> 23)) - 127 + 15; // Exponent unbias the single, then bias the halfp
-                if( hes >= 0x1F ) {  // Overflow
-                    *hp++ = (uint16_t) ((xs >> 16) | 0x7C00u); // Signed Inf
-                } else if( hes <= 0 ) {  // Underflow
-                    if( (14 - hes) > 24 ) {  // Mantissa shifted all the way off & no rounding possibility
-                        hm = (uint16_t) 0u;  // Set mantissa to zero
-                    } else {
-                        xm |= 0x00800000u;  // Add the hidden leading bit
-                        hm = (uint16_t) (xm >> (14 - hes)); // Mantissa
-                        if( (xm >> (13 - hes)) & 0x00000001u ) // Check for rounding
-                            hm += (uint16_t) 1u; // Round, might overflow into exp bit, but this is OK
-                    }
-                    *hp++ = (hs | hm); // Combine sign bit and mantissa bits, biased exponent is zero
-                } else {
-                    he = (uint16_t) (hes << 10); // Exponent
-                    hm = (uint16_t) (xm >> 13); // Mantissa
-                    if( xm & 0x00001000u ) // Check for rounding
-                        *hp++ = (hs | he | hm) + (uint16_t) 1u; // Round, might overflow to inf, this is OK
-                    else
-                        *hp++ = (hs | he | hm);  // No rounding
-                }
-            }
-        }
-    }
-}
-#endif
-
-//-----------------------------------------------------------------------------
-
 static void halfp2doubles(void *target, void *source, long numel)
 {
     uint16_t *hp = (uint16_t *) source; // Type pun input as an unsigned 16-bit int
@@ -245,15 +137,15 @@ static void halfp2doubles(void *target, void *source, long numel)
     uint32_t xs, xe, xm;
     int32_t xes;
     int e;
-
-    xp += next;  // Little Endian adjustment if necessary
     
     if( source == NULL || target == NULL ) // Nothing to convert (e.g., imag part of pure real)
         return;
     while( numel-- ) {
+        uint32_t x;
+
         h = *hp++;
         if( (h & 0x7FFFu) == 0 ) {  // Signed zero
-            *xp++ = ((uint32_t) h) << 16;  // Return the signed zero
+            x = ((uint32_t) h) << 16;  // Return the signed zero
         } else { // Not zero
             hs = h & 0x8000u;  // Pick off sign bit
             he = h & 0x7C00u;  // Pick off exponent bits
@@ -268,22 +160,26 @@ static void halfp2doubles(void *target, void *source, long numel)
                 xes = ((int32_t) (he >> 10)) - 15 + 1023 - e; // Exponent unbias the halfp, then bias the double
                 xe = (uint32_t) (xes << 20); // Exponent
                 xm = ((uint32_t) (hm & 0x03FFu)) << 10; // Mantissa
-                *xp++ = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
+                x = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
             } else if( he == 0x7C00u ) {  // Inf or NaN (all the exponent bits are set)
                 if( hm == 0 ) { // If mantissa is zero ...
-                    *xp++ = (((uint32_t) hs) << 16) | ((uint32_t) 0x7FF00000u); // Signed Inf
+                    x = (((uint32_t) hs) << 16) | ((uint32_t) 0x7FF00000u); // Signed Inf
                 } else {
-                    *xp++ = (uint32_t) 0xFFF80000u; // NaN, only the 1st mantissa bit set
+                    x = (uint32_t) 0xFFF80000u; // NaN, only the 1st mantissa bit set
                 }
             } else {
                 xs = ((uint32_t) hs) << 16; // Sign bit
                 xes = ((int32_t) (he >> 10)) - 15 + 1023; // Exponent unbias the halfp, then bias the double
                 xe = (uint32_t) (xes << 20); // Exponent
                 xm = ((uint32_t) hm) << 10; // Mantissa
-                *xp++ = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
+                x = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
             }
         }
-        xp++; // Skip over the remaining 32 bits of the mantissa
+
+       xp[1 - next] = 0;
+       xp[next] = x;
+
+       xp += 2;
     }
 }
 
index 159ef0ab4ef1182c19858cc90033014bcc511c44..4ba3e331c90739298cb31adc759a32ffb921b589 100644 (file)
 /* Define to 1 if AltiVec support is available. */
 #undef USE_ALTIVEC
 
+/* Define to 1 if f16c intrinsics are available. */
+#undef USE_F16C
+
 /* Define to 1 if MMX assembly is available. */
 #undef USE_MMX
 
 
 /* Define to 1 if SSE2 assembly is available. */
 #undef USE_SSE2
+
+/* Define to 1 if SSE4_1 assembly is available. */
+#undef USE_SSE4_1
index dc0c339ba98490d9e7204b4d7e78e3712de7478a..2cc2fd9c69218fb638ee8b48509bdff7e9b0a68f 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for babl 0.1.14.
+# Generated by GNU Autoconf 2.69 for babl 0.1.16.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='babl'
 PACKAGE_TARNAME='babl'
-PACKAGE_VERSION='0.1.14'
-PACKAGE_STRING='babl 0.1.14'
+PACKAGE_VERSION='0.1.16'
+PACKAGE_STRING='babl 0.1.16'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -636,6 +636,8 @@ LIBOBJS
 HAVE_SRANDOM_FALSE
 HAVE_SRANDOM_TRUE
 ALTIVEC_EXTRA_CFLAGS
+F16C_EXTRA_CFLAGS
+SSE4_1_EXTRA_CFLAGS
 SSE2_EXTRA_CFLAGS
 SSE_EXTRA_CFLAGS
 MMX_EXTRA_CFLAGS
@@ -812,6 +814,8 @@ enable_docs
 enable_mmx
 enable_sse
 enable_sse2
+enable_sse4_1
+enable_f16c
 enable_altivec
 '
       ac_precious_vars='build_alias
@@ -1373,7 +1377,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures babl 0.1.14 to adapt to many kinds of systems.
+\`configure' configures babl 0.1.16 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1445,7 +1449,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of babl 0.1.14:";;
+     short | recursive ) echo "Configuration of babl 0.1.16:";;
    esac
   cat <<\_ACEOF
 
@@ -1471,6 +1475,8 @@ Optional Features:
   --enable-mmx            enable MMX support (default=auto)
   --enable-sse            enable SSE support (default=auto)
   --enable-sse2            enable SSE2 support (default=auto)
+  --enable-sse4_1            enable SSE4_1 support (default=auto)
+  --enable-f16c            enable hardware half-float support (default=auto)
   --enable-altivec        enable AltiVec support (default=auto)
 
 Optional Packages:
@@ -1558,7 +1564,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-babl configure 0.1.14
+babl configure 0.1.16
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1923,7 +1929,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by babl $as_me 0.1.14, which was
+It was created by babl $as_me 0.1.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2279,11 +2285,11 @@ ac_config_headers="$ac_config_headers config.h"
 
 BABL_MAJOR_VERSION=0
 BABL_MINOR_VERSION=1
-BABL_MICRO_VERSION=14
+BABL_MICRO_VERSION=16
 BABL_INTERFACE_AGE=1
-BABL_BINARY_AGE=114
-BABL_VERSION=0.1.14
-BABL_REAL_VERSION=0.1.14
+BABL_BINARY_AGE=116
+BABL_VERSION=0.1.16
+BABL_REAL_VERSION=0.1.16
 BABL_API_VERSION=0.1
 
 
@@ -2318,7 +2324,7 @@ fi
 
 
 
-BABL_LIBRARY_VERSION="113:1:113"
+BABL_LIBRARY_VERSION="115:1:115"
 BABL_CURRENT_MINUS_AGE=0
 
 
@@ -2950,7 +2956,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='babl'
- VERSION='0.1.14'
+ VERSION='0.1.16'
 
 
 # Some tools Automake needs.
@@ -12961,6 +12967,22 @@ else
 fi
 
 
+# Check whether --enable-sse4_1 was given.
+if test "${enable_sse4_1+set}" = set; then :
+  enableval=$enable_sse4_1;
+else
+  enable_sse4_1=$enable_sse
+fi
+
+
+# Check whether --enable-f16c was given.
+if test "${enable_f16c+set}" = set; then :
+  enableval=$enable_f16c;
+else
+  enable_f16c=$enable_sse
+fi
+
+
 if test "x$enable_mmx" = xyes; then
 
   MMX_EXTRA_CFLAGS=
@@ -12998,6 +13020,7 @@ $as_echo "$MMX_EXTRA_CFLAGS_works" >&6; }
 
   SSE_EXTRA_CFLAGS=
   SSE2_EXTRA_CFLAGS=
+  SSE4_1_EXTRA_CFLAGS=
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile MMX code" >&5
 $as_echo_n "checking whether we can compile MMX code... " >&6; }
@@ -13232,6 +13255,150 @@ $as_echo "no" >&6; }
           { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The assembler does not support the SSE2 command set." >&5
 $as_echo "$as_me: WARNING: The assembler does not support the SSE2 command set." >&2;}
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+        if test "x$enable_sse4_1" = xyes; then
+
+  sse4_1_flag=
+  for flag in '-msse4.1'; do
+    if test -z "$sse4_1_flag"; then
+      sse4_1_flag_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS $flag"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands $flag" >&5
+$as_echo_n "checking whether $CC understands $flag... " >&6; }
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  sse4_1_flag_works=yes
+else
+  sse4_1_flag_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sse4_1_flag_works" >&5
+$as_echo "$sse4_1_flag_works" >&6; }
+      CFLAGS="$sse4_1_flag_save_CFLAGS"
+      if test "x$sse4_1_flag_works" = "xyes"; then
+        sse4_1_flag="$flag"
+      fi
+    fi
+  done
+
+          SSE4_1_EXTRA_CFLAGS="$SSE_EXTRA_CFLAGS $sse4_1_flag"
+
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile SSE4_1 code" >&5
+$as_echo_n "checking whether we can compile SSE4_1 code... " >&6; }
+
+          CFLAGS="$CFLAGS $sse4_1_flag"
+
+          cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+asm ("pmovzxbd %xmm0,%xmm1");
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define USE_SSE4_1 1" >>confdefs.h
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+  enable_sse4_1=no
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The assembler does not support the SSE4_1 command set." >&5
+$as_echo "$as_me: WARNING: The assembler does not support the SSE4_1 command set." >&2;}
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+        fi
+      fi
+
+      CFLAGS="$mmx_save_CFLAGS"
+
+      if test "x$enable_f16c" = xyes; then
+
+  f16c_flag=
+  for flag in '-mf16c'; do
+    if test -z "$f16c_flag"; then
+      f16c_flag_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS $flag"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands $flag" >&5
+$as_echo_n "checking whether $CC understands $flag... " >&6; }
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  f16c_flag_works=yes
+else
+  f16c_flag_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $f16c_flag_works" >&5
+$as_echo "$f16c_flag_works" >&6; }
+      CFLAGS="$f16c_flag_save_CFLAGS"
+      if test "x$f16c_flag_works" = "xyes"; then
+        f16c_flag="$flag"
+      fi
+    fi
+  done
+
+        F16C_EXTRA_CFLAGS="$SSE_EXTRA_CFLAGS $f16c_flag"
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile half-floating point code" >&5
+$as_echo_n "checking whether we can compile half-floating point code... " >&6; }
+
+        CFLAGS="$CFLAGS $sse_flag $f16c_flag"
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <immintrin.h>
+int
+main ()
+{
+__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps());
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define USE_F16C 1" >>confdefs.h
+
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+  enable_f16c=no
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+          { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The compiler does not support f16c intrinsics." >&5
+$as_echo "$as_me: WARNING: The compiler does not support f16c intrinsics." >&2;}
+
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
       fi
@@ -13253,6 +13420,8 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
 
+
+
 fi
 
 
@@ -14155,7 +14324,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by babl $as_me 0.1.14, which was
+This file was extended by babl $as_me 0.1.16, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14221,7 +14390,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-babl config.status 0.1.14
+babl config.status 0.1.16
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index 53803f5fffd5ddd37babd1d5da3545225ea21c00..30b88d19282b0da66d11920dcc2b93be4b33ddc5 100644 (file)
@@ -14,7 +14,7 @@ AC_PREREQ(2.54)
 
 m4_define([babl_major_version], [0])
 m4_define([babl_minor_version], [1])
-m4_define([babl_micro_version], [14])
+m4_define([babl_micro_version], [16])
 m4_define([babl_real_version],
           [babl_major_version.babl_minor_version.babl_micro_version])
 m4_define([babl_version], [babl_real_version])
@@ -299,10 +299,19 @@ AC_ARG_ENABLE(sse2,
   [  --enable-sse2            enable SSE2 support (default=auto)],,
   enable_sse2=$enable_sse)
 
+AC_ARG_ENABLE(sse4_1,
+  [  --enable-sse4_1            enable SSE4_1 support (default=auto)],,
+  enable_sse4_1=$enable_sse)
+
+AC_ARG_ENABLE(f16c,
+  [  --enable-f16c            enable hardware half-float support (default=auto)],,
+  enable_f16c=$enable_sse)
+
 if test "x$enable_mmx" = xyes; then
   BABL_DETECT_CFLAGS(MMX_EXTRA_CFLAGS, '-mmmx')
   SSE_EXTRA_CFLAGS=
   SSE2_EXTRA_CFLAGS=
+  SSE4_1_EXTRA_CFLAGS=
 
   AC_MSG_CHECKING(whether we can compile MMX code)
 
@@ -353,6 +362,44 @@ if test "x$enable_mmx" = xyes; then
           AC_MSG_RESULT(no)
           AC_MSG_WARN([The assembler does not support the SSE2 command set.])
         )
+
+        if test "x$enable_sse4_1" = xyes; then
+          BABL_DETECT_CFLAGS(sse4_1_flag, '-msse4.1')
+          SSE4_1_EXTRA_CFLAGS="$SSE_EXTRA_CFLAGS $sse4_1_flag"
+
+          AC_MSG_CHECKING(whether we can compile SSE4_1 code)
+
+          CFLAGS="$CFLAGS $sse4_1_flag"
+
+          AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[asm ("pmovzxbd %xmm0,%xmm1");])],
+            AC_DEFINE(USE_SSE4_1, 1, [Define to 1 if SSE4_1 assembly is available.])
+            AC_MSG_RESULT(yes)
+          ,
+            enable_sse4_1=no
+            AC_MSG_RESULT(no)
+            AC_MSG_WARN([The assembler does not support the SSE4_1 command set.])
+          )
+        fi
+      fi
+
+      CFLAGS="$mmx_save_CFLAGS"
+
+      if test "x$enable_f16c" = xyes; then
+        BABL_DETECT_CFLAGS(f16c_flag, '-mf16c')
+        F16C_EXTRA_CFLAGS="$SSE_EXTRA_CFLAGS $f16c_flag"
+
+        AC_MSG_CHECKING(whether we can compile half-floating point code)
+
+        CFLAGS="$CFLAGS $sse_flag $f16c_flag"
+
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <immintrin.h>],[__m128 val = _mm_cvtph_ps ((__m128i)_mm_setzero_ps());])],
+          AC_DEFINE(USE_F16C, 1, [Define to 1 if f16c intrinsics are available.])
+          AC_MSG_RESULT(yes)
+        ,
+          enable_f16c=no
+          AC_MSG_RESULT(no)
+          AC_MSG_WARN([The compiler does not support f16c intrinsics.])
+        )
       fi
 
     fi
@@ -367,6 +414,8 @@ if test "x$enable_mmx" = xyes; then
   AC_SUBST(MMX_EXTRA_CFLAGS)
   AC_SUBST(SSE_EXTRA_CFLAGS)
   AC_SUBST(SSE2_EXTRA_CFLAGS)
+  AC_SUBST(SSE4_1_EXTRA_CFLAGS)
+  AC_SUBST(F16C_EXTRA_CFLAGS)
 fi
 
 
index eddff64b4a31c350e5026af8ca5ba22b2ce07428..e991f4f9d374b87d4bebe89f010eb77c3e826e5e 100644 (file)
@@ -222,6 +222,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -265,6 +266,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
index 492f77d547921d7ac393f3f64d5b8cd8302f9a97..cff8d7cbff033b75a78826b39200da13189ab61d 100644 (file)
@@ -162,6 +162,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -205,6 +206,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
index aea6726cedd077078db077698a41f224fabb7c54..57ad178affd0a31a67e5f99115c15214199d729c 100644 (file)
Binary files a/docs/graphics/babl-16x16.png and b/docs/graphics/babl-16x16.png differ
index 7a8e1cc885e3c42b0f99694743a3f18edc8a0b8b..717e95d4d517f0e086773a1c6171219d880379b5 100644 (file)
Binary files a/docs/graphics/babl-48x48.png and b/docs/graphics/babl-48x48.png differ
index 85c4d4d5a8949ac54b3aa4e630011ebc44b77497..8b21a08aa7d02e535f4f8aebd2c2346c2e8b84a9 100644 (file)
Binary files a/docs/graphics/babl-a4poster.png and b/docs/graphics/babl-a4poster.png differ
index a09ef06c55d0a2336b970838871c659705d4cabf..2e0aca2609d26ac2fccfa7e9cd92e5ec5f236ff9 100644 (file)
@@ -467,6 +467,42 @@ Yaf_to_Laf (float *src,
   return samples;
 }
 
+static long
+rgbf_to_Labf (float *src,
+              float *dst,
+              long   samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      float r = src[0];
+      float g = src[1];
+      float b = src[2];
+
+      float xr = 0.43603516f / D50_WHITE_REF_X * r + 0.38511658f / D50_WHITE_REF_X * g + 0.14305115f / D50_WHITE_REF_X * b;
+      float yr = 0.22248840f / D50_WHITE_REF_Y * r + 0.71690369f / D50_WHITE_REF_Y * g + 0.06060791f / D50_WHITE_REF_Y * b;
+      float zr = 0.01391602f / D50_WHITE_REF_Z * r + 0.09706116f / D50_WHITE_REF_Z * g + 0.71392822f / D50_WHITE_REF_Z * b;
+
+      float fx = xr > LAB_EPSILON ? cbrtf (xr) : (LAB_KAPPA * xr + 16.0f) / 116.0f;
+      float fy = yr > LAB_EPSILON ? cbrtf (yr) : (LAB_KAPPA * yr + 16.0f) / 116.0f;
+      float fz = zr > LAB_EPSILON ? cbrtf (zr) : (LAB_KAPPA * zr + 16.0f) / 116.0f;
+
+      float L = 116.0f * fy - 16.0f;
+      float A = 500.0f * (fx - fy);
+      float B = 200.0f * (fy - fz);
+
+      dst[0] = L;
+      dst[1] = A;
+      dst[2] = B;
+
+      src += 3;
+      dst += 3;
+    }
+
+  return samples;
+}
+
 static long
 rgbaf_to_Labaf (float *src,
                 float *dst,
@@ -505,6 +541,42 @@ rgbaf_to_Labaf (float *src,
   return samples;
 }
 
+static long
+Labf_to_rgbf (float *src,
+                float *dst,
+                long   samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      float L = src[0];
+      float A = src[1];
+      float B = src[2];
+
+      float fy = (L + 16.0f) / 116.0f;
+      float fx = fy + A / 500.0f;
+      float fz = fy - B / 200.0f;
+
+      float yr = L > LAB_KAPPA * LAB_EPSILON ? cubef (fy) : L / LAB_KAPPA;
+      float xr = cubef (fx) > LAB_EPSILON ? cubef (fx) : (fx * 116.0f - 16.0f) / LAB_KAPPA;
+      float zr = cubef (fz) > LAB_EPSILON ? cubef (fz) : (fz * 116.0f - 16.0f) / LAB_KAPPA;
+
+      float r =  3.134274799724f * D50_WHITE_REF_X * xr -1.617275708956f * D50_WHITE_REF_Y * yr -0.490724283042f * D50_WHITE_REF_Z * zr;
+      float g = -0.978795575994f * D50_WHITE_REF_X * xr +1.916161689117f * D50_WHITE_REF_Y * yr +0.033453331711f * D50_WHITE_REF_Z * zr;
+      float b =  0.071976988401f * D50_WHITE_REF_X * xr -0.228984974402f * D50_WHITE_REF_Y * yr +1.405718224383f * D50_WHITE_REF_Z * zr;
+
+      dst[0] = r;
+      dst[1] = g;
+      dst[2] = b;
+
+      src += 3;
+      dst += 3;
+    }
+
+  return samples;
+}
+
 static long
 Labaf_to_rgbaf (float *src,
                 float *dst,
@@ -570,6 +642,18 @@ conversions (void)
     "linear", laba_to_rgba,
     NULL
   );
+  babl_conversion_new (
+    babl_format ("RGB float"),
+    babl_format ("CIE Lab float"),
+    "linear", rgbf_to_Labf,
+    NULL
+  );
+  babl_conversion_new (
+    babl_format ("CIE Lab float"),
+    babl_format ("RGB float"),
+    "linear", Labf_to_rgbf,
+    NULL
+  );
   babl_conversion_new (
     babl_format ("RGBA float"),
     babl_format ("CIE Lab alpha float"),
index 4a3fb8a343b553b72471ef754de69d3edcb6b5b7..7ecb45741b6effd207fbd2128dfe353bda729323 100644 (file)
@@ -17,8 +17,11 @@ extdir = $(libdir)/babl-@BABL_API_VERSION@
 ext_LTLIBRARIES = \
        cairo.la        \
        CIE.la          \
+    float-half.la   \
        gegl-fixups.la  \
        gggl-lies.la    \
+       gggl-table.la   \
+       gggl-table-lies.la \
        gggl.la         \
        gimp-8bit.la    \
        grey.la         \
@@ -31,14 +34,19 @@ ext_LTLIBRARIES = \
        sse2-float.la   \
        sse2-int8.la    \
        sse2-int16.la   \
+       sse4-int8.la    \
+       sse-half.la     \
        two-table.la    \
        ycbcr.la
 
 cairo_la_SOURCES = cairo.c cairo-tables.h
 CIE_la_SOURCES = CIE.c
 simple_la_SOURCES = simple.c
+float_half_la_SOURCES = float-half.c
 gegl_fixups_la_SOURCES = gegl-fixups.c
 gggl_lies_la_SOURCES = gggl-lies.c
+gggl_table_lies_la_SOURCES = gggl-table-lies.c
+gggl_table_la_SOURCES = gggl-table.c
 gggl_la_SOURCES = gggl.c
 gimp_8bit_la_SOURCES = gimp-8bit.c
 grey_la_SOURCES = grey.c
@@ -48,6 +56,8 @@ HSV_la_SOURCES = HSV.c
 sse2_float_la_SOURCES = sse2-float.c
 sse2_int8_la_SOURCES = sse2-int8.c
 sse2_int16_la_SOURCES = sse2-int16.c
+sse4_int8_la_SOURCES = sse4-int8.c
+sse_half_la_SOURCES = sse-half.c
 two_table_la_SOURCES = two-table.c two-table-tables.h
 ycbcr_la_SOURCES = ycbcr.c
 float_la_SOURCES = float.c
@@ -59,3 +69,5 @@ LIBS = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la $(MATH_LIB) \
 sse2_float_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
 sse2_int8_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
 sse2_int16_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
+sse4_int8_la_CFLAGS = $(SSE4_1_EXTRA_CFLAGS)
+sse_half_la_CFLAGS = $(SSE4_1_EXTRA_CFLAGS) $(F16C_EXTRA_CFLAGS)
index fa3d0dfa7761484cf67634615caf7d60fe316e37..0ba52161ebf851176f0ceeed3fd23b2a1752298c 100644 (file)
@@ -152,6 +152,9 @@ cairo_la_OBJECTS = $(am_cairo_la_OBJECTS)
 fast_float_la_LIBADD =
 am_fast_float_la_OBJECTS = fast-float.lo
 fast_float_la_OBJECTS = $(am_fast_float_la_OBJECTS)
+float_half_la_LIBADD =
+am_float_half_la_OBJECTS = float-half.lo
+float_half_la_OBJECTS = $(am_float_half_la_OBJECTS)
 float_la_LIBADD =
 am_float_la_OBJECTS = float.lo
 float_la_OBJECTS = $(am_float_la_OBJECTS)
@@ -161,6 +164,12 @@ gegl_fixups_la_OBJECTS = $(am_gegl_fixups_la_OBJECTS)
 gggl_lies_la_LIBADD =
 am_gggl_lies_la_OBJECTS = gggl-lies.lo
 gggl_lies_la_OBJECTS = $(am_gggl_lies_la_OBJECTS)
+gggl_table_lies_la_LIBADD =
+am_gggl_table_lies_la_OBJECTS = gggl-table-lies.lo
+gggl_table_lies_la_OBJECTS = $(am_gggl_table_lies_la_OBJECTS)
+gggl_table_la_LIBADD =
+am_gggl_table_la_OBJECTS = gggl-table.lo
+gggl_table_la_OBJECTS = $(am_gggl_table_la_OBJECTS)
 gggl_la_LIBADD =
 am_gggl_la_OBJECTS = gggl.lo
 gggl_la_OBJECTS = $(am_gggl_la_OBJECTS)
@@ -176,6 +185,12 @@ naive_CMYK_la_OBJECTS = $(am_naive_CMYK_la_OBJECTS)
 simple_la_LIBADD =
 am_simple_la_OBJECTS = simple.lo
 simple_la_OBJECTS = $(am_simple_la_OBJECTS)
+sse_half_la_LIBADD =
+am_sse_half_la_OBJECTS = sse_half_la-sse-half.lo
+sse_half_la_OBJECTS = $(am_sse_half_la_OBJECTS)
+sse_half_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(sse_half_la_CFLAGS) \
+       $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 sse2_float_la_LIBADD =
 am_sse2_float_la_OBJECTS = sse2_float_la-sse2-float.lo
 sse2_float_la_OBJECTS = $(am_sse2_float_la_OBJECTS)
@@ -194,6 +209,12 @@ sse2_int8_la_OBJECTS = $(am_sse2_int8_la_OBJECTS)
 sse2_int8_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(sse2_int8_la_CFLAGS) \
        $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+sse4_int8_la_LIBADD =
+am_sse4_int8_la_OBJECTS = sse4_int8_la-sse4-int8.lo
+sse4_int8_la_OBJECTS = $(am_sse4_int8_la_OBJECTS)
+sse4_int8_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(sse4_int8_la_CFLAGS) \
+       $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 two_table_la_LIBADD =
 am_two_table_la_OBJECTS = two-table.lo
 two_table_la_OBJECTS = $(am_two_table_la_OBJECTS)
@@ -236,21 +257,25 @@ am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \
        $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \
-       $(float_la_SOURCES) $(gegl_fixups_la_SOURCES) \
-       $(gggl_lies_la_SOURCES) $(gggl_la_SOURCES) \
-       $(gimp_8bit_la_SOURCES) $(grey_la_SOURCES) \
+       $(float_half_la_SOURCES) $(float_la_SOURCES) \
+       $(gegl_fixups_la_SOURCES) $(gggl_lies_la_SOURCES) \
+       $(gggl_table_lies_la_SOURCES) $(gggl_table_la_SOURCES) \
+       $(gggl_la_SOURCES) $(gimp_8bit_la_SOURCES) $(grey_la_SOURCES) \
        $(naive_CMYK_la_SOURCES) $(simple_la_SOURCES) \
-       $(sse2_float_la_SOURCES) $(sse2_int16_la_SOURCES) \
-       $(sse2_int8_la_SOURCES) $(two_table_la_SOURCES) \
+       $(sse_half_la_SOURCES) $(sse2_float_la_SOURCES) \
+       $(sse2_int16_la_SOURCES) $(sse2_int8_la_SOURCES) \
+       $(sse4_int8_la_SOURCES) $(two_table_la_SOURCES) \
        $(ycbcr_la_SOURCES)
 DIST_SOURCES = $(CIE_la_SOURCES) $(HSL_la_SOURCES) $(HSV_la_SOURCES) \
        $(cairo_la_SOURCES) $(fast_float_la_SOURCES) \
-       $(float_la_SOURCES) $(gegl_fixups_la_SOURCES) \
-       $(gggl_lies_la_SOURCES) $(gggl_la_SOURCES) \
-       $(gimp_8bit_la_SOURCES) $(grey_la_SOURCES) \
+       $(float_half_la_SOURCES) $(float_la_SOURCES) \
+       $(gegl_fixups_la_SOURCES) $(gggl_lies_la_SOURCES) \
+       $(gggl_table_lies_la_SOURCES) $(gggl_table_la_SOURCES) \
+       $(gggl_la_SOURCES) $(gimp_8bit_la_SOURCES) $(grey_la_SOURCES) \
        $(naive_CMYK_la_SOURCES) $(simple_la_SOURCES) \
-       $(sse2_float_la_SOURCES) $(sse2_int16_la_SOURCES) \
-       $(sse2_int8_la_SOURCES) $(two_table_la_SOURCES) \
+       $(sse_half_la_SOURCES) $(sse2_float_la_SOURCES) \
+       $(sse2_int16_la_SOURCES) $(sse2_int8_la_SOURCES) \
+       $(sse4_int8_la_SOURCES) $(two_table_la_SOURCES) \
        $(ycbcr_la_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -318,6 +343,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -363,6 +389,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
@@ -440,8 +467,11 @@ extdir = $(libdir)/babl-@BABL_API_VERSION@
 ext_LTLIBRARIES = \
        cairo.la        \
        CIE.la          \
+    float-half.la   \
        gegl-fixups.la  \
        gggl-lies.la    \
+       gggl-table.la   \
+       gggl-table-lies.la \
        gggl.la         \
        gimp-8bit.la    \
        grey.la         \
@@ -454,14 +484,19 @@ ext_LTLIBRARIES = \
        sse2-float.la   \
        sse2-int8.la    \
        sse2-int16.la   \
+       sse4-int8.la    \
+       sse-half.la     \
        two-table.la    \
        ycbcr.la
 
 cairo_la_SOURCES = cairo.c cairo-tables.h
 CIE_la_SOURCES = CIE.c
 simple_la_SOURCES = simple.c
+float_half_la_SOURCES = float-half.c
 gegl_fixups_la_SOURCES = gegl-fixups.c
 gggl_lies_la_SOURCES = gggl-lies.c
+gggl_table_lies_la_SOURCES = gggl-table-lies.c
+gggl_table_la_SOURCES = gggl-table.c
 gggl_la_SOURCES = gggl.c
 gimp_8bit_la_SOURCES = gimp-8bit.c
 grey_la_SOURCES = grey.c
@@ -471,6 +506,8 @@ HSV_la_SOURCES = HSV.c
 sse2_float_la_SOURCES = sse2-float.c
 sse2_int8_la_SOURCES = sse2-int8.c
 sse2_int16_la_SOURCES = sse2-int16.c
+sse4_int8_la_SOURCES = sse4-int8.c
+sse_half_la_SOURCES = sse-half.c
 two_table_la_SOURCES = two-table.c two-table-tables.h
 ycbcr_la_SOURCES = ycbcr.c
 float_la_SOURCES = float.c
@@ -478,6 +515,8 @@ fast_float_la_SOURCES = fast-float.c
 sse2_float_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
 sse2_int8_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
 sse2_int16_la_CFLAGS = $(SSE2_EXTRA_CFLAGS)
+sse4_int8_la_CFLAGS = $(SSE4_1_EXTRA_CFLAGS)
+sse_half_la_CFLAGS = $(SSE4_1_EXTRA_CFLAGS) $(F16C_EXTRA_CFLAGS)
 all: all-am
 
 .SUFFIXES:
@@ -562,6 +601,9 @@ cairo.la: $(cairo_la_OBJECTS) $(cairo_la_DEPENDENCIES) $(EXTRA_cairo_la_DEPENDEN
 fast-float.la: $(fast_float_la_OBJECTS) $(fast_float_la_DEPENDENCIES) $(EXTRA_fast_float_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(fast_float_la_OBJECTS) $(fast_float_la_LIBADD) $(LIBS)
 
+float-half.la: $(float_half_la_OBJECTS) $(float_half_la_DEPENDENCIES) $(EXTRA_float_half_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(float_half_la_OBJECTS) $(float_half_la_LIBADD) $(LIBS)
+
 float.la: $(float_la_OBJECTS) $(float_la_DEPENDENCIES) $(EXTRA_float_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(float_la_OBJECTS) $(float_la_LIBADD) $(LIBS)
 
@@ -571,6 +613,12 @@ gegl-fixups.la: $(gegl_fixups_la_OBJECTS) $(gegl_fixups_la_DEPENDENCIES) $(EXTRA
 gggl-lies.la: $(gggl_lies_la_OBJECTS) $(gggl_lies_la_DEPENDENCIES) $(EXTRA_gggl_lies_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(gggl_lies_la_OBJECTS) $(gggl_lies_la_LIBADD) $(LIBS)
 
+gggl-table-lies.la: $(gggl_table_lies_la_OBJECTS) $(gggl_table_lies_la_DEPENDENCIES) $(EXTRA_gggl_table_lies_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(gggl_table_lies_la_OBJECTS) $(gggl_table_lies_la_LIBADD) $(LIBS)
+
+gggl-table.la: $(gggl_table_la_OBJECTS) $(gggl_table_la_DEPENDENCIES) $(EXTRA_gggl_table_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(gggl_table_la_OBJECTS) $(gggl_table_la_LIBADD) $(LIBS)
+
 gggl.la: $(gggl_la_OBJECTS) $(gggl_la_DEPENDENCIES) $(EXTRA_gggl_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(gggl_la_OBJECTS) $(gggl_la_LIBADD) $(LIBS)
 
@@ -586,6 +634,9 @@ naive-CMYK.la: $(naive_CMYK_la_OBJECTS) $(naive_CMYK_la_DEPENDENCIES) $(EXTRA_na
 simple.la: $(simple_la_OBJECTS) $(simple_la_DEPENDENCIES) $(EXTRA_simple_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(simple_la_OBJECTS) $(simple_la_LIBADD) $(LIBS)
 
+sse-half.la: $(sse_half_la_OBJECTS) $(sse_half_la_DEPENDENCIES) $(EXTRA_sse_half_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(sse_half_la_LINK) -rpath $(extdir) $(sse_half_la_OBJECTS) $(sse_half_la_LIBADD) $(LIBS)
+
 sse2-float.la: $(sse2_float_la_OBJECTS) $(sse2_float_la_DEPENDENCIES) $(EXTRA_sse2_float_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(sse2_float_la_LINK) -rpath $(extdir) $(sse2_float_la_OBJECTS) $(sse2_float_la_LIBADD) $(LIBS)
 
@@ -595,6 +646,9 @@ sse2-int16.la: $(sse2_int16_la_OBJECTS) $(sse2_int16_la_DEPENDENCIES) $(EXTRA_ss
 sse2-int8.la: $(sse2_int8_la_OBJECTS) $(sse2_int8_la_DEPENDENCIES) $(EXTRA_sse2_int8_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(sse2_int8_la_LINK) -rpath $(extdir) $(sse2_int8_la_OBJECTS) $(sse2_int8_la_LIBADD) $(LIBS)
 
+sse4-int8.la: $(sse4_int8_la_OBJECTS) $(sse4_int8_la_DEPENDENCIES) $(EXTRA_sse4_int8_la_DEPENDENCIES) 
+       $(AM_V_CCLD)$(sse4_int8_la_LINK) -rpath $(extdir) $(sse4_int8_la_OBJECTS) $(sse4_int8_la_LIBADD) $(LIBS)
+
 two-table.la: $(two_table_la_OBJECTS) $(two_table_la_DEPENDENCIES) $(EXTRA_two_table_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(LINK) -rpath $(extdir) $(two_table_la_OBJECTS) $(two_table_la_LIBADD) $(LIBS)
 
@@ -612,9 +666,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HSV.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cairo.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fast-float.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float-half.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gegl-fixups.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gggl-lies.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gggl-table-lies.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gggl-table.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gggl.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimp-8bit.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grey.Plo@am__quote@
@@ -623,6 +680,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse2_float_la-sse2-float.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse2_int16_la-sse2-int16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse2_int8_la-sse2-int8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse4_int8_la-sse4-int8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sse_half_la-sse-half.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/two-table.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ycbcr.Plo@am__quote@
 
@@ -647,6 +706,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
+sse_half_la-sse-half.lo: sse-half.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sse_half_la_CFLAGS) $(CFLAGS) -MT sse_half_la-sse-half.lo -MD -MP -MF $(DEPDIR)/sse_half_la-sse-half.Tpo -c -o sse_half_la-sse-half.lo `test -f 'sse-half.c' || echo '$(srcdir)/'`sse-half.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/sse_half_la-sse-half.Tpo $(DEPDIR)/sse_half_la-sse-half.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sse-half.c' object='sse_half_la-sse-half.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sse_half_la_CFLAGS) $(CFLAGS) -c -o sse_half_la-sse-half.lo `test -f 'sse-half.c' || echo '$(srcdir)/'`sse-half.c
+
 sse2_float_la-sse2-float.lo: sse2-float.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sse2_float_la_CFLAGS) $(CFLAGS) -MT sse2_float_la-sse2-float.lo -MD -MP -MF $(DEPDIR)/sse2_float_la-sse2-float.Tpo -c -o sse2_float_la-sse2-float.lo `test -f 'sse2-float.c' || echo '$(srcdir)/'`sse2-float.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/sse2_float_la-sse2-float.Tpo $(DEPDIR)/sse2_float_la-sse2-float.Plo
@@ -668,6 +734,13 @@ sse2_int8_la-sse2-int8.lo: sse2-int8.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sse2_int8_la_CFLAGS) $(CFLAGS) -c -o sse2_int8_la-sse2-int8.lo `test -f 'sse2-int8.c' || echo '$(srcdir)/'`sse2-int8.c
 
+sse4_int8_la-sse4-int8.lo: sse4-int8.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sse4_int8_la_CFLAGS) $(CFLAGS) -MT sse4_int8_la-sse4-int8.lo -MD -MP -MF $(DEPDIR)/sse4_int8_la-sse4-int8.Tpo -c -o sse4_int8_la-sse4-int8.lo `test -f 'sse4-int8.c' || echo '$(srcdir)/'`sse4-int8.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/sse4_int8_la-sse4-int8.Tpo $(DEPDIR)/sse4_int8_la-sse4-int8.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='sse4-int8.c' object='sse4_int8_la-sse4-int8.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sse4_int8_la_CFLAGS) $(CFLAGS) -c -o sse4_int8_la-sse4-int8.lo `test -f 'sse4-int8.c' || echo '$(srcdir)/'`sse4-int8.c
+
 mostlyclean-libtool:
        -rm -f *.lo
 
diff --git a/extensions/float-half.c b/extensions/float-half.c
new file mode 100644 (file)
index 0000000..ff37625
--- /dev/null
@@ -0,0 +1,356 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2015 Daniel Sabo
+ *               2016 Øyvind Kolås
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+/* Copyright:   (c) 2009 by James Tursa, All Rights Reserved
+ *
+ *  This code uses the BSD License:
+ *
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions are 
+ *  met:
+ *
+ *     * Redistributions of source code must retain the above copyright 
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright 
+ *       notice, this list of conditions and the following disclaimer in 
+ *       the documentation and/or other materials provided with the distribution
+ *      
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
+ *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
+ *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ * halfprecision converts the input argument to/from a half precision floating
+ * point bit pattern corresponding to IEEE 754r. The bit pattern is stored in a
+ * uint16 class variable. Please note that halfprecision is *not* a class. That
+ * is, you cannot do any arithmetic with the half precision bit patterns.
+ * halfprecision is simply a function that converts the IEEE 754r half precision
+ * bit pattern to/from other numeric MATLAB variables. You can, however, take
+ * the half precision bit patterns, convert them to single or double, do the
+ * operation, and then convert the result back manually.
+ *
+ * 1 bit sign bit
+ * 5 bits exponent, biased by 15
+ * 10 bits mantissa, hidden leading bit, normalized to 1.0
+ *
+ * Special floating point bit patterns recognized and supported:
+ *
+ * All exponent bits zero:
+ * - If all mantissa bits are zero, then number is zero (possibly signed)
+ * - Otherwise, number is a denormalized bit pattern
+ *
+ * All exponent bits set to 1:
+ * - If all mantissa bits are zero, then number is +Infinity or -Infinity
+ * - Otherwise, number is NaN (Not a Number)
+ */
+
+#include "config.h"
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "babl.h"
+#include "extensions/util.h"
+
+static void halfp2singles(void *target, const void *source, long numel)
+{
+    uint16_t *hp = (uint16_t *) source; // Type pun input as an unsigned 16-bit int
+    uint32_t *xp = (uint32_t *) target; // Type pun output as an unsigned 32-bit int
+    uint16_t h, hs, he, hm;
+    uint32_t xs, xe, xm;
+    int32_t xes;
+    int e;
+    
+    if( source == NULL || target == NULL ) // Nothing to convert (e.g., imag part of pure real)
+        return;
+    while( numel-- ) {
+        h = *hp++;
+        if( (h & 0x7FFFu) == 0 ) {  // Signed zero
+            *xp++ = ((uint32_t) h) << 16;  // Return the signed zero
+        } else { // Not zero
+            hs = h & 0x8000u;  // Pick off sign bit
+            he = h & 0x7C00u;  // Pick off exponent bits
+            hm = h & 0x03FFu;  // Pick off mantissa bits
+            if( he == 0 ) {  // Denormal will convert to normalized
+                e = -1; // The following loop figures out how much extra to adjust the exponent
+                do {
+                    e++;
+                    hm <<= 1;
+                } while( (hm & 0x0400u) == 0 ); // Shift until leading bit overflows into exponent bit
+                xs = ((uint32_t) hs) << 16; // Sign bit
+                xes = ((int32_t) (he >> 10)) - 15 + 127 - e; // Exponent unbias the halfp, then bias the single
+                xe = (uint32_t) (xes << 23); // Exponent
+                xm = ((uint32_t) (hm & 0x03FFu)) << 13; // Mantissa
+                *xp++ = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
+            } else if( he == 0x7C00u ) {  // Inf or NaN (all the exponent bits are set)
+                if( hm == 0 ) { // If mantissa is zero ...
+                    *xp++ = (((uint32_t) hs) << 16) | ((uint32_t) 0x7F800000u); // Signed Inf
+                } else {
+                    *xp++ = (uint32_t) 0xFFC00000u; // NaN, only 1st mantissa bit set
+                }
+            } else { // Normalized number
+                xs = ((uint32_t) hs) << 16; // Sign bit
+                xes = ((int32_t) (he >> 10)) - 15 + 127; // Exponent unbias the halfp, then bias the single
+                xe = (uint32_t) (xes << 23); // Exponent
+                xm = ((uint32_t) hm) << 13; // Mantissa
+                *xp++ = (xs | xe | xm); // Combine sign bit, exponent bits, and mantissa bits
+            }
+        }
+    }
+}
+
+static void singles2halfp(void *target, const void *source, long numel)
+{
+    uint16_t *hp = (uint16_t *) target; // Type pun output as an unsigned 16-bit int
+    uint32_t *xp = (uint32_t *) source; // Type pun input as an unsigned 32-bit int
+    uint16_t    hs, he, hm;
+    uint32_t x, xs, xe, xm;
+    int hes;
+    
+    if( source == NULL || target == NULL ) { // Nothing to convert (e.g., imag part of pure real)
+        return;
+    }
+    while( numel-- ) {
+        x = *xp++;
+        if( (x & 0x7FFFFFFFu) == 0 ) {  // Signed zero
+            *hp++ = (uint16_t) (x >> 16);  // Return the signed zero
+        } else { // Not zero
+            xs = x & 0x80000000u;  // Pick off sign bit
+            xe = x & 0x7F800000u;  // Pick off exponent bits
+            xm = x & 0x007FFFFFu;  // Pick off mantissa bits
+            if( xe == 0 ) {  // Denormal will underflow, return a signed zero
+                *hp++ = (uint16_t) (xs >> 16);
+            } else if( xe == 0x7F800000u ) {  // Inf or NaN (all the exponent bits are set)
+                if( xm == 0 ) { // If mantissa is zero ...
+                    *hp++ = (uint16_t) ((xs >> 16) | 0x7C00u); // Signed Inf
+                } else {
+                    *hp++ = (uint16_t) 0xFE00u; // NaN, only 1st mantissa bit set
+                }
+            } else { // Normalized number
+                hs = (uint16_t) (xs >> 16); // Sign bit
+                hes = ((int)(xe >> 23)) - 127 + 15; // Exponent unbias the single, then bias the halfp
+                if( hes >= 0x1F ) {  // Overflow
+                    *hp++ = (uint16_t) ((xs >> 16) | 0x7C00u); // Signed Inf
+                } else if( hes <= 0 ) {  // Underflow
+                    if( (14 - hes) > 24 ) {  // Mantissa shifted all the way off & no rounding possibility
+                        hm = (uint16_t) 0u;  // Set mantissa to zero
+                    } else {
+                        xm |= 0x00800000u;  // Add the hidden leading bit
+                        hm = (uint16_t) (xm >> (14 - hes)); // Mantissa
+                        if( (xm >> (13 - hes)) & 0x00000001u ) // Check for rounding
+                            hm += (uint16_t) 1u; // Round, might overflow into exp bit, but this is OK
+                    }
+                    *hp++ = (hs | hm); // Combine sign bit and mantissa bits, biased exponent is zero
+                } else {
+                   he = (uint16_t) (hes << 10); // Exponent
+                    hm = (uint16_t) (xm >> 13); // Mantissa
+                    if( xm & 0x00001000u ) // Check for rounding
+                        *hp++ = (hs | he | hm) + (uint16_t) 1u; // Round, might overflow to inf, this is OK
+                    else
+                        *hp++ = (hs | he | hm);  // No rounding
+                }
+            }
+        }
+    }
+}
+
+static inline long
+conv_yHalf_yF (const uint16_t *src, float *dst, long samples)
+{
+  halfp2singles(dst, src, samples);
+  return samples;
+}
+
+static long
+conv_yaHalf_yaF (const uint16_t *src, float *dst, long samples)
+{
+  return conv_yHalf_yF (src, dst, samples * 2) / 2;
+}
+
+static long
+conv_rgbHalf_rgbF (const uint16_t *src, float *dst, long samples)
+{
+  return conv_yHalf_yF (src, dst, samples * 3) / 3;
+}
+
+static long
+conv_rgbaHalf_rgbaF (const uint16_t *src, float *dst, long samples)
+{
+  return conv_yHalf_yF (src, dst, samples * 4) / 4;
+}
+
+static inline long
+conv_yF_yHalf (const float *src, uint16_t *dst, long samples)
+{
+  singles2halfp (dst, src, samples);
+  return samples;
+}
+
+static long
+conv_yaF_yaHalf (const float *src, uint16_t *dst, long samples)
+{
+  return conv_yF_yHalf (src, dst, samples * 2) / 2;
+}
+
+static long
+conv_rgbF_rgbHalf (const float *src, uint16_t *dst, long samples)
+{
+  return conv_yF_yHalf (src, dst, samples * 3) / 3;
+}
+
+static long
+conv_rgbaF_rgbaHalf (const float *src, uint16_t *dst, long samples)
+{
+  return conv_yF_yHalf (src, dst, samples * 4) / 4;
+}
+
+int init (void);
+
+int
+init (void)
+{
+  const Babl *rgbaF_linear = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaHalf_linear = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("half"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaF_gamma = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaHalf_gamma = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("half"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbF_linear = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgbHalf_linear = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("half"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgbF_gamma = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *rgbHalf_gamma = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("half"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *yaF_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaHalf_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("half"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaF_gamma = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaHalf_gamma = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("half"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yF_linear = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *yHalf_linear = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("half"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *yF_gamma = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    NULL);
+  const Babl *yHalf_gamma = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("half"),
+    babl_component ("Y'"),
+    NULL);
+
+#define CONV(src, dst) \
+{ \
+  babl_conversion_new (src ## _linear, dst ## _linear, "linear", conv_ ## src ## _ ## dst, NULL); \
+  babl_conversion_new (src ## _gamma, dst ## _gamma, "linear", conv_ ## src ## _ ## dst, NULL); \
+}
+
+  CONV(rgbaHalf, rgbaF);
+  CONV(rgbHalf,  rgbF);
+  CONV(yaHalf,   yaF);
+  CONV(yHalf,    yF);
+  CONV(rgbaF,    rgbaHalf);
+  CONV(rgbF,     rgbHalf);
+  CONV(yaF,      yaHalf);
+  CONV(yF,       yHalf);
+
+  return 0;
+}
index 91304d65656ef659879fb90ca83926b0e555dfd2..22d0fee96f8917a48f4ba91723a2b8c97c3f9811 100644 (file)
  *       gamma correction  (not really,. gamma correction belongs in seperate ops,.
  */
 
-#define USE_TABLES
-#ifdef USE_TABLES
-
-/* lookup tables used in conversion */
-
-static float          table_8_F[1 << 8];
-static float          table_16_F[1 << 16];
-static unsigned char  table_F_8[1 << 16];
-static unsigned short table_F_16[1 << 16];
-
-
-static int table_inited = 0;
-
-static void
-table_init (void)
-{
-  int i;
-
-  if (table_inited)
-    return;
-  table_inited = 1;
-
-  /* fill tables for conversion from integer to float */
-  for (i = 0; i < 1 << 8; i++)
-    {
-      table_8_F[i] = (i * 1.0) / 255.0;
-    }
-  for (i = 0; i < 1 << 16; i++)
-    {
-      table_16_F[i] = (i * 1.0) / 65535.0;
-    }
-  /* fill tables for conversion from float to integer */
-  {
-    union
-    {
-      float          f;
-      unsigned short s[2];
-    } u;
-    u.f = 0.0;
-
-    u.s[0] = 0x8000;
-
-    for (i = 0; i < 1 << 16; i++)
-      {
-        unsigned char  c;
-        unsigned short s;
-
-        u.s[1] = i;
-
-        if (u.f <= 0.0)
-          {
-            c = 0;
-            s = 0;
-          }
-        else if (u.f >= 1.0)
-          {
-            c = 255;
-            s = 65535;
-          }
-        else
-          {
-            c = lrint (u.f * 255.0);
-            s = lrint (u.f * 65535.0);
-          }
-
-        /*fprintf (stderr, "%2.3f=%03i %05i ", f, c, (*hi));
-           / if (! ((*hi)%9))
-           /         fprintf (stderr, "\n"); */
-
-        table_F_8[u.s[1]]  = c;
-        table_F_16[u.s[1]] = s;
-      }
-  }
-  /* fix tables to ensure 1:1 conversions back and forth */
-  if (0)
-    {                           /*FIXME: probably not the right way to do it,.. must sit down and scribble on paper */
-      int i;
-      for (i = 0; i < 256; i++)
-        {
-          float           f  = table_8_F[i];
-          unsigned short *hi = ((unsigned short *) (void *) &f);
-          unsigned short *lo = ((unsigned short *) (void *) &f);
-          *lo              = 0;
-          table_F_8[(*hi)] = i;
-        }
-    }
-}
-
-/* function to find the index in table for a float */
-static unsigned int
-gggl_float_to_index16 (float f)
-{
-  union
-  {
-    float          f;
-    unsigned short s[2];
-  } u;
-  u.f = f;
-  return u.s[1];
-}
-
-
-static long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      register float f = (*(float *) src);
-      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      dst                   += 1;
-      src                   += 4;
-    }
-  return samples;
-}
-
-static long
-conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      register float f = (*(float *) src);
-      *(unsigned short *) dst = table_F_16[gggl_float_to_index16 (f)];
-      dst                    += 2;
-      src                    += 4;
-    }
-  return samples;
-}
-
-static long
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      (*(float *) dst) = table_8_F[*(unsigned char *) src];
-      dst             += 4;
-      src             += 1;
-    }
-  return samples;
-}
-
-static long
-conv_16_F (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      (*(float *) dst) = table_16_F[*(unsigned short *) src];
-      dst             += 4;
-      src             += 2;
-    }
-  return samples;
-}
-
-#else
-
 static long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -302,9 +132,6 @@ conv_16_F (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-
-#endif
-
 static long
 conv_F_D (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -319,7 +146,6 @@ conv_F_D (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-
 static long
 conv_D_F (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -1050,10 +876,5 @@ init (void)
   o (rgba8, rgb8);
   o (rgbaF, rgbA8);
 
-#ifdef USE_TABLES
-  if (!table_inited)
-    table_init ();
-#endif
-
   return 0;
 }
diff --git a/extensions/gggl-table-lies.c b/extensions/gggl-table-lies.c
new file mode 100644 (file)
index 0000000..3e79a6f
--- /dev/null
@@ -0,0 +1,479 @@
+/*
+ * This file was part of gggl, it implements a variety of pixel conversion
+ * functions that are usable with babl, the file needs more cleanup, and
+ * doesn't return the number of samples processed as a long, like it's
+ * supposed to.
+ *
+ *    GGGL is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 3 of the License, or
+ *    (at your option) any later version.
+ *
+ *    GGGL is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *    Rights are granted to use this shared object in libraries covered by
+ *    LGPL. (exception added, during import into babl CVS.)
+ *
+ *  Copyright 2003, 2004, 2005 Øyvind Kolås <pippin@gimp.org>
+ */
+
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+#include <math.h>
+#include <string.h>
+
+#include "babl.h"
+#include "extensions/util.h"
+
+/*
+ * Implemented according to information read from:
+ *
+ * http://www.cinenet.net/~spitzak/conversion/sketches_0265.pdf
+ *
+ * initially ignoring any diffusion, to keep the implementation
+ * smaller, and interchangeable with the non optimized version.
+ *
+ * due to ability to be able to relicence gggl under a different
+ * licence than GPL, I avoided the temptation to look at the
+ * source files in the same location, in case I was going to
+ * need this piece of code for projects where GPL compatibility
+ * was a must.
+ *
+ * TODO: error diffusion,
+ *       gamma correction  (not really,. gamma correction belongs in seperate ops,.
+ */
+
+/* lookup tables used in conversion */
+
+static float          table_8_F[1 << 8];
+static float          table_16_F[1 << 16];
+static unsigned char  table_F_8[1 << 16];
+static unsigned short table_F_16[1 << 16];
+
+
+static int table_inited = 0;
+
+static void
+table_init (void)
+{
+  int i;
+
+  if (table_inited)
+    return;
+  table_inited = 1;
+
+  /* fill tables for conversion from integer to float */
+  for (i = 0; i < 1 << 8; i++)
+    {
+      table_8_F[i] = (i * 1.0) / 255.0;
+    }
+  for (i = 0; i < 1 << 16; i++)
+    {
+      table_16_F[i] = (i * 1.0) / 65535.0;
+    }
+  /* fill tables for conversion from float to integer */
+  {
+    union
+    {
+      float          f;
+      unsigned short s[2];
+    } u;
+    u.f = 0.0;
+
+    u.s[0] = 0x8000;
+
+    for (i = 0; i < 1 << 16; i++)
+      {
+        unsigned char  c;
+        unsigned short s;
+
+        u.s[1] = i;
+
+        if (u.f <= 0.0)
+          {
+            c = 0;
+            s = 0;
+          }
+        else if (u.f >= 1.0)
+          {
+            c = 255;
+            s = 65535;
+          }
+        else
+          {
+            c = lrint (u.f * 255.0);
+            s = lrint (u.f * 65535.0);
+          }
+
+        /*fprintf (stderr, "%2.3f=%03i %05i ", f, c, (*hi));
+           / if (! ((*hi)%9))
+           /         fprintf (stderr, "\n"); */
+
+        table_F_8[u.s[1]]  = c;
+        table_F_16[u.s[1]] = s;
+      }
+  }
+  /* fix tables to ensure 1:1 conversions back and forth */
+  if (0)
+    {                           /*FIXME: probably not the right way to do it,.. must sit down and scribble on paper */
+      int i;
+      for (i = 0; i < 256; i++)
+        {
+          float           f  = table_8_F[i];
+          unsigned short *hi = ((unsigned short *) (void *) &f);
+          unsigned short *lo = ((unsigned short *) (void *) &f);
+          *lo              = 0;
+          table_F_8[(*hi)] = i;
+        }
+    }
+}
+
+/* function to find the index in table for a float */
+static unsigned int
+gggl_float_to_index16 (float f)
+{
+  union
+  {
+    float          f;
+    unsigned short s[2];
+  } u;
+  u.f = f;
+  return u.s[1];
+}
+
+
+static long
+conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      register float f = (*(float *) src);
+      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+      dst                   += 1;
+      src                   += 4;
+    }
+  return samples;
+}
+
+static long
+conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      register float f = (*(float *) src);
+      *(unsigned short *) dst = table_F_16[gggl_float_to_index16 (f)];
+      dst                    += 2;
+      src                    += 4;
+    }
+  return samples;
+}
+
+static long
+conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      (*(float *) dst) = table_8_F[*(unsigned char *) src];
+      dst             += 4;
+      src             += 1;
+    }
+  return samples;
+}
+
+static long
+conv_16_F (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      (*(float *) dst) = table_16_F[*(unsigned short *) src];
+      dst             += 4;
+      src             += 2;
+    }
+  return samples;
+}
+
+/*********/
+static long
+conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_8 (src, dst, samples * 4);
+  return samples;
+}
+
+#define conv_rgbaF_rgbP8    conv_rgbaF_rgba8
+
+static long
+conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_8 (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_8 (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbAF_rgbA8    conv_rgbaF_rgba8
+#define conv_gF_g8          conv_F_8
+#define conv_gAF_gA8        conv_gaF_ga8
+
+static long
+conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_16 (src, dst, samples * 4);
+  return samples;
+}
+
+static long
+conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_16 (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_16 (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbAF_rgbA16    conv_rgbaF_rgba16
+#define conv_gF_g16          conv_F_16
+#define conv_gAF_gA16        conv_gaF_ga16
+
+static long
+conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_8_F (src, dst, samples * 4);
+  return samples;
+}
+
+static long
+conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_8_F (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_8_F (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbA8_rgbAF    conv_rgba8_rgbaF
+#define conv_gA8_gAF        conv_ga8_gaF
+#define conv_g8_gF          conv_8_F
+
+static long
+conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_16_F (src, dst, samples * 4);
+  return samples;
+}
+
+static long
+conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_16_F (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_16_F (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbA16_rgbAF    conv_rgba16_rgbaF
+#define conv_gA16_gAF        conv_ga16_gaF
+#define conv_g16_gF          conv_16_F
+
+int init (void);
+
+int
+init (void)
+{
+  const Babl *rgbaF = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgba16 = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("u16"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgba8 = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("u8"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbAF = babl_format_new (
+    babl_model ("RaGaBaA"),
+    babl_type ("float"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbA16 = babl_format_new (
+    babl_model ("RaGaBaA"),
+    babl_type ("u16"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbA8 = babl_format_new (
+    babl_model ("RaGaBaA"),
+    babl_type ("u8"),
+    babl_component ("Ra"),
+    babl_component ("Ga"),
+    babl_component ("Ba"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbF = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgb16 = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("u16"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgb8 = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("u8"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *gaF = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gAF = babl_format_new (
+    babl_model ("YaA"),
+    babl_type ("float"),
+    babl_component ("Ya"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gF = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *ga16 = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("u16"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gA16 = babl_format_new (
+    babl_model ("YaA"),
+    babl_type ("u16"),
+    babl_component ("Ya"),
+    babl_component ("A"),
+    NULL);
+  const Babl *g16 = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("u16"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *ga8 = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("u8"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gA8 = babl_format_new (
+    babl_model ("YaA"),
+    babl_type ("u8"),
+    babl_component ("Ya"),
+    babl_component ("A"),
+    NULL);
+  const Babl *g8 = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("u8"),
+    babl_component ("Y"),
+    NULL);
+
+#define o(src, dst) \
+  babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
+
+  o (rgbaF, rgba8);
+  o (rgba8, rgbaF);
+  o (rgbaF, rgba16);
+  o (rgba16, rgbaF);
+  o (rgbAF, rgbA8);
+  o (rgbA8, rgbAF);
+  o (rgbAF, rgbA16);
+  o (rgbA16, rgbAF);
+  o (rgbF, rgb8);
+  o (rgb8, rgbF);
+  o (rgbF, rgb16);
+  o (rgb16, rgbF);
+  o (gaF, ga8);
+  o (gAF, gA8);
+  o (gF, g8);
+  o (ga8, gaF);
+  o (gA8, gAF);
+  o (g8, gF);
+  o (gaF, ga16);
+  o (gAF, gA16);
+  o (gF, g16);
+  o (ga16, gaF);
+  o (gA16, gAF);
+  o (g16, gF);
+
+  if (!table_inited)
+    table_init ();
+
+  return 0;
+}
diff --git a/extensions/gggl-table.c b/extensions/gggl-table.c
new file mode 100644 (file)
index 0000000..071167d
--- /dev/null
@@ -0,0 +1,528 @@
+/*
+ * This file was part of gggl, it implements a variety of pixel conversion
+ * functions that are usable with babl, the file needs more cleanup.
+ *
+ *    GGGL is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 3 of the License, or
+ *    (at your option) any later version.
+ *
+ *    GGGL is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with GGGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *    Rights are granted to use this shared object in libraries covered by
+ *    LGPL. (exception added, during import into babl CVS.)
+ *
+ *  Copyright 2003, 2004, 2005 Øyvind Kolås <pippin@gimp.org>
+ */
+
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+#include <math.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "babl.h"
+#include "extensions/util.h"
+
+/*
+ * Implemented according to information read from:
+ *
+ * http://www.cinenet.net/~spitzak/conversion/sketches_0265.pdf
+ *
+ * initially ignoring any diffusion, to keep the implementation
+ * smaller, and interchangeable with the non optimized version.
+ *
+ * due to ability to be able to relicence gggl under a different
+ * licence than GPL, I avoided the temptation to look at the
+ * source files in the same location, in case I was going to
+ * need this piece of code for projects where GPL compatibility
+ * was a must.
+ *
+ * TODO: error diffusion,
+ *       gamma correction  (not really,. gamma correction belongs in seperate ops,.
+ */
+
+/* lookup tables used in conversion */
+
+static float          table_8_F[1 << 8];
+static float          table_16_F[1 << 16];
+static unsigned char  table_F_8[1 << 16];
+static unsigned short table_F_16[1 << 16];
+
+static uint32_t      *table_8_F_int = NULL;
+
+static int table_inited = 0;
+
+static void
+table_init (void)
+{
+  if (table_inited)
+    return;
+  
+  table_8_F_int = (void*)(table_8_F);
+
+  table_inited = 1;
+
+  /* fill tables for conversion from integer to float */
+  {
+    int i;
+    for (i = 0; i < 1 << 8; i++)
+      {
+        table_8_F[i] = (i * 1.0) / 255.0;
+      }
+    for (i = 0; i < 1 << 16; i++)
+      table_16_F[i] = (i * 1.0) / 65535.0;
+  }
+  /* fill tables for conversion from float to integer */
+  {
+    union
+    {
+      float          f;
+      unsigned short s[2];
+    } u;
+    u.f = 0.0;
+
+    u.s[0] = 0x8000;
+
+    for (u.s[1] = 0; u.s[1] < 65535; u.s[1] += 1)
+      {
+        unsigned char  c;
+        unsigned short s;
+
+        if (u.f <= 0.0)
+          {
+            c = 0;
+            s = 0;
+          }
+        else if (u.f >= 1.0)
+          {
+            c = 255;
+            s = 65535;
+          }
+        else
+          {
+            c = lrint (u.f * 255.0);
+            s = lrint (u.f * 65535.0);
+          }
+
+        /*fprintf (stderr, "%2.3f=%03i %05i ", f, c, (*hi));
+           / if (! ((*hi)%9))
+           /         fprintf (stderr, "\n"); */
+
+        table_F_8[u.s[1]]  = c;
+        table_F_16[u.s[1]] = s;
+      }
+  }
+  /* fix tables to ensure 1:1 conversions back and forth */
+  if (0)
+    {                           /*FIXME: probably not the right way to do it,.. must sit down and scribble on paper */
+      int i;
+      for (i = 0; i < 256; i++)
+        {
+          float           f  = table_8_F[i];
+          unsigned short *hi = ((unsigned short *) (void *) &f);
+          unsigned short *lo = ((unsigned short *) (void *) &f);
+          *lo              = 0;
+          table_F_8[(*hi)] = i;
+        }
+    }
+}
+
+/* function to find the index in table for a float */
+static unsigned int
+gggl_float_to_index16 (float f)
+{
+  union
+  {
+    float          f;
+    unsigned short s[2];
+  } u;
+  u.f = f;
+  return u.s[1];
+}
+
+static long
+conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      register float f = (*(float *) src);
+      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+      dst                   += 1;
+      src                   += 4;
+    }
+  return samples;
+}
+
+static long
+conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      register float f = (*(float *) src);
+      *(unsigned short *) dst = table_F_16[gggl_float_to_index16 (f)];
+      dst                    += 2;
+      src                    += 4;
+    }
+  return samples;
+}
+
+static long
+conv_8_F (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+      dst             += 4;
+      src             += 1;
+    }
+  return samples;
+}
+
+static long
+conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+      dst             += 4;
+      src             += 1;
+      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+      dst             += 4;
+      src             += 1;
+      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+      dst             += 4;
+      src             += 1;
+      (*(float    *) dst) = 1.0;
+      dst             += 4;
+    }
+  return samples;
+}
+
+static long
+conv_16_F (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  if (!table_inited)
+    table_init ();
+  while (n--)
+    {
+      (*(float *) dst) = table_16_F[*(unsigned short *) src];
+      dst             += 4;
+      src             += 2;
+    }
+  return samples;
+}
+
+static long
+conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  long n = samples;
+
+  while (n--)
+    {
+      register float f = (*(float *) src);
+      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+      src                   += 4;
+      dst                   += 1;
+
+      f                      = (*(float *) src);
+      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+      src                   += 4;
+      dst                   += 1;
+
+      f                      = (*(float *) src);
+      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
+      src                   += 4;
+      dst                   += 1;
+
+      src += 4;
+    }
+  return samples;
+}
+
+
+/*********/
+static long
+conv_rgbaF_rgba8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_8 (src, dst, samples * 4);
+  return samples;
+}
+
+static long
+conv_rgbF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_8 (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_gaF_ga8 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_8 (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbAF_rgbA8    conv_rgbaF_rgba8
+#define conv_gF_g8          conv_F_8
+#define conv_gAF_gA8        conv_gaF_ga8
+
+static long
+conv_rgbaF_rgba16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_16 (src, dst, samples * 4);
+  return samples;
+}
+
+static long
+conv_rgbF_rgb16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_16 (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_gaF_ga16 (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_F_16 (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbAF_rgbA16    conv_rgbaF_rgba16
+#define conv_gF_g16          conv_F_16
+#define conv_gAF_gA16        conv_gaF_ga16
+
+static long
+conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  return conv_8_F (src, dst, samples * 4) / 4;
+}
+
+
+static long
+conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
+{
+  return conv_8_F (src, dst, samples * 3) / 3;
+}
+
+static long
+conv_ga8_gaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  return conv_8_F (src, dst, samples * 2) / 2;
+}
+
+#define conv_rgbA8_rgbAF    conv_rgba8_rgbaF
+#define conv_gA8_gAF        conv_ga8_gaF
+#define conv_g8_gF          conv_8_F
+
+static long
+conv_rgba16_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_16_F (src, dst, samples * 4);
+  return samples;
+}
+
+static long
+conv_rgb16_rgbF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_16_F (src, dst, samples * 3);
+  return samples;
+}
+
+static long
+conv_ga16_gaF (unsigned char *src, unsigned char *dst, long samples)
+{
+  conv_16_F (src, dst, samples * 2);
+  return samples;
+}
+
+#define conv_rgbA16_rgbAF    conv_rgba16_rgbaF
+#define conv_gA16_gAF        conv_ga16_gaF
+#define conv_g16_gF          conv_16_F
+
+int init (void);
+
+int
+init (void)
+{
+  const Babl *rgbaF = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgba16 = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("u16"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgba8 = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbAF = babl_format_new (
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("float"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbA16 = babl_format_new (
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("u16"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbA8 = babl_format_new (
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("u8"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbF = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *rgb16 = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("u16"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *rgb8 = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *gaF = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gAF = babl_format_new (
+    babl_model ("Y'aA"),
+    babl_type ("float"),
+    babl_component ("Y'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gF = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    NULL);
+  const Babl *ga16 = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("u16"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gA16 = babl_format_new (
+    babl_model ("Y'aA"),
+    babl_type ("u16"),
+    babl_component ("Y'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *g16 = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("u16"),
+    babl_component ("Y'"),
+    NULL);
+  const Babl *ga8 = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("u8"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *gA8 = babl_format_new (
+    babl_model ("Y'aA"),
+    babl_type ("u8"),
+    babl_component ("Y'a"),
+    babl_component ("A"),
+    NULL);
+  const Babl *g8 = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("u8"),
+    babl_component ("Y'"),
+    NULL);
+
+#define o(src, dst) \
+  babl_conversion_new (src, dst, "linear", conv_ ## src ## _ ## dst, NULL)
+
+  o (rgbaF, rgba8);
+  o (rgba8, rgbaF);
+  o (rgbaF, rgba16);
+  o (rgba16, rgbaF);
+  o (rgbAF, rgbA8);
+  o (rgbA8, rgbAF);
+  o (rgbAF, rgbA16);
+  o (rgbA16, rgbAF);
+  o (rgbF, rgb8);
+  o (rgb8, rgbF);
+  o (rgbF, rgb16);
+  o (rgb16, rgbF);
+  o (gaF, ga8);
+  o (gAF, gA8);
+  o (gF, g8);
+  o (ga8, gaF);
+  o (gA8, gAF);
+  o (g8, gF);
+  o (gaF, ga16);
+  o (gAF, gA16);
+  o (gF, g16);
+  o (ga16, gaF);
+  o (gA16, gAF);
+  o (g16, gF);
+  o (rgbaF, rgb8);
+  o (rgb8, rgbaF);
+
+  if (!table_inited)
+    table_init ();
+
+  return 0;
+}
index e9fc1d9eff699409668c17b8b2fa1f04d6385f73..7ab4400dedc60616d26254153d74151010f21433 100644 (file)
  *       gamma correction  (not really,. gamma correction belongs in seperate ops,.
  */
 
-#define USE_TABLES
-#ifdef USE_TABLES
-
-/* lookup tables used in conversion */
-
-static float          table_8_F[1 << 8];
-static float          table_16_F[1 << 16];
-static unsigned char  table_F_8[1 << 16];
-static unsigned short table_F_16[1 << 16];
-
-static uint32_t      *table_8_F_int = NULL;
-
-static int table_inited = 0;
-
-static void
-table_init (void)
-{
-  if (table_inited)
-    return;
-  
-  table_8_F_int = (void*)(table_8_F);
-
-  table_inited = 1;
-
-  /* fill tables for conversion from integer to float */
-  {
-    int i;
-    for (i = 0; i < 1 << 8; i++)
-      {
-        table_8_F[i] = (i * 1.0) / 255.0;
-      }
-    for (i = 0; i < 1 << 16; i++)
-      table_16_F[i] = (i * 1.0) / 65535.0;
-  }
-  /* fill tables for conversion from float to integer */
-  {
-    union
-    {
-      float          f;
-      unsigned short s[2];
-    } u;
-    u.f = 0.0;
-
-    u.s[0] = 0x8000;
-
-    for (u.s[1] = 0; u.s[1] < 65535; u.s[1] += 1)
-      {
-        unsigned char  c;
-        unsigned short s;
-
-        if (u.f <= 0.0)
-          {
-            c = 0;
-            s = 0;
-          }
-        else if (u.f >= 1.0)
-          {
-            c = 255;
-            s = 65535;
-          }
-        else
-          {
-            c = lrint (u.f * 255.0);
-            s = lrint (u.f * 65535.0);
-          }
-
-        /*fprintf (stderr, "%2.3f=%03i %05i ", f, c, (*hi));
-           / if (! ((*hi)%9))
-           /         fprintf (stderr, "\n"); */
-
-        table_F_8[u.s[1]]  = c;
-        table_F_16[u.s[1]] = s;
-      }
-  }
-  /* fix tables to ensure 1:1 conversions back and forth */
-  if (0)
-    {                           /*FIXME: probably not the right way to do it,.. must sit down and scribble on paper */
-      int i;
-      for (i = 0; i < 256; i++)
-        {
-          float           f  = table_8_F[i];
-          unsigned short *hi = ((unsigned short *) (void *) &f);
-          unsigned short *lo = ((unsigned short *) (void *) &f);
-          *lo              = 0;
-          table_F_8[(*hi)] = i;
-        }
-    }
-}
-
-/* function to find the index in table for a float */
-static unsigned int
-gggl_float_to_index16 (float f)
-{
-  union
-  {
-    float          f;
-    unsigned short s[2];
-  } u;
-  u.f = f;
-  return u.s[1];
-}
-
-static long
-conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      register float f = (*(float *) src);
-      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      dst                   += 1;
-      src                   += 4;
-    }
-  return samples;
-}
-
-static long
-conv_F_16 (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      register float f = (*(float *) src);
-      *(unsigned short *) dst = table_F_16[gggl_float_to_index16 (f)];
-      dst                    += 2;
-      src                    += 4;
-    }
-  return samples;
-}
-
-static long
-conv_8_F (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
-      dst             += 4;
-      src             += 1;
-    }
-  return samples;
-}
-
-static long
-conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
-      dst             += 4;
-      src             += 1;
-      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
-      dst             += 4;
-      src             += 1;
-      (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
-      dst             += 4;
-      src             += 1;
-      (*(float    *) dst) = 1.0;
-      dst             += 4;
-    }
-  return samples;
-}
-
-static long
-conv_16_F (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  if (!table_inited)
-    table_init ();
-  while (n--)
-    {
-      (*(float *) dst) = table_16_F[*(unsigned short *) src];
-      dst             += 4;
-      src             += 2;
-    }
-  return samples;
-}
-
-static long
-conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
-{
-  long n = samples;
-
-  while (n--)
-    {
-      register float f = (*(float *) src);
-      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src                   += 4;
-      dst                   += 1;
-
-      f                      = (*(float *) src);
-      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src                   += 4;
-      dst                   += 1;
-
-      f                      = (*(float *) src);
-      *(unsigned char *) dst = table_F_8[gggl_float_to_index16 (f)];
-      src                   += 4;
-      dst                   += 1;
-
-      src += 4;
-    }
-  return samples;
-}
-
-#else
-
 static long
 conv_F_8 (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -370,9 +149,6 @@ conv_rgbaF_rgb8 (unsigned char *src, unsigned char *dst, long samples)
   return samples;
 }
 
-#endif
-
-
 static long
 conv_F_D (unsigned char *src, unsigned char *dst, long samples)
 {
@@ -673,7 +449,7 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
       *(uint32_t *) dst = (*(uint32_t *) src);
       src           += 4;
       dst           += 4;
-      *(uint32_t *) dst = 1.0;
+      *(float *) dst = 1.0;
       dst           += 4;
     }
   return samples;
@@ -1340,12 +1116,6 @@ init (void)
   o (rgbA16, rgbaF);
   o (rgbaF, rgbaD);
   o (rgbaD, rgbaF);
-  o (rgb8, rgbaF);
-
-#ifdef USE_TABLES
-  if (!table_inited)
-    table_init ();
-#endif
 
   return 0;
 }
diff --git a/extensions/sse-half.c b/extensions/sse-half.c
new file mode 100644 (file)
index 0000000..e20c214
--- /dev/null
@@ -0,0 +1,270 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2015 Daniel Sabo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#if defined(USE_SSE4_1) && defined(USE_F16C) && defined(ARCH_X86_64)
+
+#include <immintrin.h>
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "babl.h"
+#include "babl-cpuaccel.h"
+#include "extensions/util.h"
+
+static inline long
+conv_yHalf_yF (const uint16_t *src, float *dst, long samples)
+{
+  const uint64_t *s_vec;
+  __v4sf         *d_vec;
+
+  long n = samples;
+
+  s_vec = (const uint64_t *)src;
+  d_vec = (__v4sf *)dst;
+
+  while (n >= 4)
+    {
+      __m128i in_val = _mm_insert_epi64((__m128i)_mm_setzero_ps(), *s_vec++, 0);
+      __v4sf out_val = (__v4sf)_mm_cvtph_ps(in_val);
+      _mm_storeu_ps((float *)d_vec++, out_val);
+      n -= 4;
+    }
+
+  src = (const uint16_t *)s_vec;
+  dst = (float *)d_vec;
+
+  while (n)
+    {
+      __m128i in_val = _mm_insert_epi16((__m128i)_mm_setzero_ps(), *src++, 0);
+      __v4sf out_val = (__v4sf)_mm_cvtph_ps(in_val);
+      _mm_store_ss(dst++, out_val);
+      n -= 1;
+    }
+
+  return samples;
+}
+
+static long
+conv_yaHalf_yaF (const uint16_t *src, float *dst, long samples)
+{
+  return conv_yHalf_yF (src, dst, samples * 2) / 2;
+}
+
+static long
+conv_rgbHalf_rgbF (const uint16_t *src, float *dst, long samples)
+{
+  return conv_yHalf_yF (src, dst, samples * 3) / 3;
+}
+
+static long
+conv_rgbaHalf_rgbaF (const uint16_t *src, float *dst, long samples)
+{
+  return conv_yHalf_yF (src, dst, samples * 4) / 4;
+}
+
+static inline long
+conv_yF_yHalf (const float *src, uint16_t *dst, long samples)
+{
+  const __v4sf *s_vec;
+  uint64_t     *d_vec;
+
+  long n = samples;
+
+  s_vec = (const __v4sf *)src;
+  d_vec = (uint64_t *)dst;
+
+  while (n >= 4)
+    {
+      __m128 in_val = _mm_loadu_ps((float *)s_vec++);
+      __m128i out_val = _mm_cvtps_ph(in_val, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
+      _mm_storel_epi64((__m128i *)d_vec++, out_val);
+      n -= 4;
+    }
+
+  src = (const float *)s_vec;
+  dst = (uint16_t *)d_vec;
+
+  while (n)
+    {
+      __m128 in_val = _mm_load_ss(src++);
+      __m128i out_val = _mm_cvtps_ph(in_val, _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC);
+      *dst++ = _mm_extract_epi16(out_val, 0);
+      n -= 1;
+    }
+
+  return samples;
+}
+
+static long
+conv_yaF_yaHalf (const float *src, uint16_t *dst, long samples)
+{
+  return conv_yF_yHalf (src, dst, samples * 2) / 2;
+}
+
+static long
+conv_rgbF_rgbHalf (const float *src, uint16_t *dst, long samples)
+{
+  return conv_yF_yHalf (src, dst, samples * 3) / 3;
+}
+
+static long
+conv_rgbaF_rgbaHalf (const float *src, uint16_t *dst, long samples)
+{
+  return conv_yF_yHalf (src, dst, samples * 4) / 4;
+}
+
+#endif /* defined(USE_SSE4_1) && defined(USE_F16C) && defined(ARCH_X86_64) */
+
+int init (void);
+
+int
+init (void)
+{
+#if defined(USE_SSE4_1) && defined(USE_F16C) && defined(ARCH_X86_64)
+  const Babl *rgbaF_linear = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaHalf_linear = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("half"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaF_gamma = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaHalf_gamma = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("half"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbF_linear = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgbHalf_linear = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("half"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgbF_gamma = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *rgbHalf_gamma = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("half"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *yaF_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaHalf_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("half"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaF_gamma = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaHalf_gamma = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("half"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yF_linear = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *yHalf_linear = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("half"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *yF_gamma = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    NULL);
+  const Babl *yHalf_gamma = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("half"),
+    babl_component ("Y'"),
+    NULL);
+
+#define CONV(src, dst) \
+{ \
+  babl_conversion_new (src ## _linear, dst ## _linear, "linear", conv_ ## src ## _ ## dst, NULL); \
+  babl_conversion_new (src ## _gamma, dst ## _gamma, "linear", conv_ ## src ## _ ## dst, NULL); \
+}
+
+  if ((babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_SSE4_1) &&
+      (babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_F16C))
+    {
+      CONV(rgbaHalf, rgbaF);
+      CONV(rgbHalf,  rgbF);
+      CONV(yaHalf,   yaF);
+      CONV(yHalf,    yF);
+      CONV(rgbaF,    rgbaHalf);
+      CONV(rgbF,     rgbHalf);
+      CONV(yaF,      yaHalf);
+      CONV(yF,       yHalf);
+    }
+
+#endif /* defined(USE_SSE4_1) && defined(USE_F16C) && defined(ARCH_X86_64) */
+
+  return 0;
+}
+
index 97b201bdf99d16e40c8fc48dfcedbf154db607e8..31b58d155d05347492f596c6c917743c25c7a00d 100644 (file)
@@ -568,6 +568,14 @@ init (void)
     babl_component ("Ba"),
     babl_component ("A"),
     NULL);
+  const Babl *rgbAF_gamma = babl_format_new (
+    babl_model ("R'aG'aB'aA"),
+    babl_type ("float"),
+    babl_component ("R'a"),
+    babl_component ("G'a"),
+    babl_component ("B'a"),
+    babl_component ("A"),
+    NULL);
   const Babl *rgbaF_gamma = babl_format_new (
     babl_model ("R'G'B'A"),
     babl_type ("float"),
@@ -622,6 +630,12 @@ init (void)
                           "linear",
                           conv_rgbaF_linear_rgbAF_linear,
                           NULL);
+
+      babl_conversion_new(rgbaF_gamma, 
+                          rgbAF_gamma,
+                          "linear",
+                          conv_rgbaF_linear_rgbAF_linear,
+                          NULL);
                           
       /* Which of these is faster varies by CPU, and the difference
        * is big enough that it's worthwhile to include both and
@@ -632,6 +646,12 @@ init (void)
                           "linear",
                           conv_rgbAF_linear_rgbaF_linear_shuffle,
                           NULL);
+      babl_conversion_new(rgbAF_gamma, 
+                          rgbaF_gamma,
+                          "linear",
+                          conv_rgbAF_linear_rgbaF_linear_shuffle,
+                          NULL);
+
       babl_conversion_new(rgbAF_linear, 
                           rgbaF_linear,
                           "linear",
diff --git a/extensions/sse4-int8.c b/extensions/sse4-int8.c
new file mode 100644 (file)
index 0000000..73f63e3
--- /dev/null
@@ -0,0 +1,218 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2013 Daniel Sabo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#if defined(USE_SSE4_1)
+
+/* SSE 4 */
+#include <smmintrin.h>
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "babl.h"
+#include "babl-cpuaccel.h"
+#include "extensions/util.h"
+
+static inline long
+conv_y8_yF (const uint8_t *src, float *dst, long samples)
+{
+  const float     factor = 1.0f / 255.0f;
+  const __v4sf    factor_vec = {1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f};
+  const uint32_t *s_vec;
+  __v4sf         *d_vec;
+
+  long n = samples;
+
+  s_vec = (const uint32_t *)src;
+  d_vec = (__v4sf *)dst;
+
+  while (n >= 4)
+    {
+      __m128i in_val;
+      __v4sf out_val;
+      in_val = _mm_insert_epi32 (in_val, *s_vec++, 0);
+      in_val = _mm_cvtepu8_epi32 (in_val);
+      out_val = _mm_cvtepi32_ps (in_val) * factor_vec;
+      _mm_storeu_ps ((float *)d_vec++, out_val);
+      n -= 4;
+    }
+
+  src = (const uint8_t *)s_vec;
+  dst = (float *)d_vec;
+
+  while (n)
+    {
+      *dst++ = (float)(*src++) * factor;
+      n -= 1;
+    }
+
+  return samples;
+}
+
+static long
+conv_ya8_yaF (const uint8_t *src, float *dst, long samples)
+{
+  return conv_y8_yF (src, dst, samples * 2) / 2;
+}
+
+static long
+conv_rgb8_rgbF (const uint8_t *src, float *dst, long samples)
+{
+  return conv_y8_yF (src, dst, samples * 3) / 3;
+}
+
+static long
+conv_rgba8_rgbaF (const uint8_t *src, float *dst, long samples)
+{
+  return conv_y8_yF (src, dst, samples * 4) / 4;
+}
+
+#endif
+
+int init (void);
+
+int
+init (void)
+{
+#if defined(USE_SSE4_1)
+  const Babl *rgbaF_linear = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgba8_linear = babl_format_new (
+    babl_model ("RGBA"),
+    babl_type ("u8"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbaF_gamma = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgba8_gamma = babl_format_new (
+    babl_model ("R'G'B'A"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *rgbF_linear = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("float"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgb8_linear = babl_format_new (
+    babl_model ("RGB"),
+    babl_type ("u8"),
+    babl_component ("R"),
+    babl_component ("G"),
+    babl_component ("B"),
+    NULL);
+  const Babl *rgbF_gamma = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("float"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *rgb8_gamma = babl_format_new (
+    babl_model ("R'G'B'"),
+    babl_type ("u8"),
+    babl_component ("R'"),
+    babl_component ("G'"),
+    babl_component ("B'"),
+    NULL);
+  const Babl *yaF_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *ya8_linear = babl_format_new (
+    babl_model ("YA"),
+    babl_type ("u8"),
+    babl_component ("Y"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yaF_gamma = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *ya8_gamma = babl_format_new (
+    babl_model ("Y'A"),
+    babl_type ("u8"),
+    babl_component ("Y'"),
+    babl_component ("A"),
+    NULL);
+  const Babl *yF_linear = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("float"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *y8_linear = babl_format_new (
+    babl_model ("Y"),
+    babl_type ("u8"),
+    babl_component ("Y"),
+    NULL);
+  const Babl *yF_gamma = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("float"),
+    babl_component ("Y'"),
+    NULL);
+  const Babl *y8_gamma = babl_format_new (
+    babl_model ("Y'"),
+    babl_type ("u8"),
+    babl_component ("Y'"),
+    NULL);
+
+#define CONV(src, dst) \
+{ \
+  babl_conversion_new (src ## _linear, dst ## _linear, "linear", conv_ ## src ## _ ## dst, NULL); \
+  babl_conversion_new (src ## _gamma, dst ## _gamma, "linear", conv_ ## src ## _ ## dst, NULL); \
+}
+
+  if ((babl_cpu_accel_get_support () & BABL_CPU_ACCEL_X86_SSE4_1))
+    {
+      CONV(rgba8, rgbaF);
+      CONV(rgb8,  rgbF);
+      CONV(ya8,   yaF);
+      CONV(y8,    yF);
+    }
+
+#endif
+
+  return 0;
+}
+
index 07c2795ca5ba9543c24059545dad98d873d5610e..a62ced56259ba24aaafaf5ec2182226a22d93f20 100644 (file)
@@ -586,6 +586,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -629,6 +630,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@
index 7ab763cc92a7013fc163922bbca2683690b16b1d..1e0f88abbb39ddbcce5cca518a901f13cc0c712c 100644 (file)
@@ -216,6 +216,7 @@ ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
 EXEEXT = @EXEEXT@
+F16C_EXTRA_CFLAGS = @F16C_EXTRA_CFLAGS@
 FGREP = @FGREP@
 GREP = @GREP@
 INSTALL = @INSTALL@
@@ -259,6 +260,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHREXT = @SHREXT@
 SSE2_EXTRA_CFLAGS = @SSE2_EXTRA_CFLAGS@
+SSE4_1_EXTRA_CFLAGS = @SSE4_1_EXTRA_CFLAGS@
 SSE_EXTRA_CFLAGS = @SSE_EXTRA_CFLAGS@
 STRIP = @STRIP@
 THREAD_LIB = @THREAD_LIB@